001
002/*
003 * $Id$
004 */
005
006package edu.jas.poly;
007
008
009import java.util.Map;
010
011import edu.jas.structure.RingElem;
012
013
014/**
015 * IndexListMonomial class. Represents pairs of index lists and coefficients.
016 * Adaptor for Map.Entry.
017 * @author Heinz Kredel
018 */
019
020public final class IndexListMonomial<C extends RingElem<C>> {
021
022
023    /**
024     * IndexList of monomial.
025     */
026    public final IndexList e;
027
028
029    /**
030     * Coefficient of monomial.
031     */
032    public final C c;
033
034
035    /**
036     * Constructor of word monomial.
037     * @param me a MapEntry.
038     */
039    public IndexListMonomial(Map.Entry<IndexList, C> me) {
040        this(me.getKey(), me.getValue());
041    }
042
043
044    /**
045     * Constructor of word monomial.
046     * @param e index list.
047     * @param c coefficient.
048     */
049    public IndexListMonomial(IndexList e, C c) {
050        this.e = e;
051        this.c = c;
052    }
053
054
055    /**
056     * Getter for index list.
057     * @return index list.
058     */
059    public IndexList indexlist() {
060        return e;
061    }
062
063
064    /**
065     * Getter for coefficient.
066     * @return coefficient.
067     */
068    public C coefficient() {
069        return c;
070    }
071
072
073    /**
074     * String representation of Monomial.
075     * @see java.lang.Object#toString()
076     */
077    @Override
078    public String toString() {
079        return c.toString() + " " + e.toString();
080    }
081
082}