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