chordDiagrams
Class Relation

java.lang.Object
  extended by chordDiagrams.Relation
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Relation>

public class Relation
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable<Relation>

This class stores a diagram relation

Author:
Romwell
See Also:
Serialized Form

Field Summary
static double epsilon
          All values with absolute value less than epsilon are counted as zeros
 java.util.TreeMap<java.lang.Integer,java.lang.Double> relation
          Holds DiagramID - Coefficient pairs
private  java.lang.String relationID
          Relation ID
static long serialVersionUID
          Serialization Version UID
 
Constructor Summary
Relation()
          Constructs an instance of the relation
 
Method Summary
static java.lang.String coefToString(double D)
          Returns a string representation of a coefficient
 int compareTo(Relation r)
          Compares this relation to another via String ID's
 boolean equals_ex(Relation r)
          Compares this relation to another relation
 boolean equals(Relation r)
           
 java.lang.String ID()
          Returns relation ID
static boolean isZero(double d)
          Tells if a double is "zero", i.e.
 boolean nonEmpty()
          Tells whether there are any terms in the relations
 void putEntry(java.lang.Integer diagID, double coef)
          Adds a diagram with a coefficient to the relation
 void setID()
          Sets the relation ID string
 int size()
          Tells how many terms there are in this relation
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

epsilon

public static final double epsilon
All values with absolute value less than epsilon are counted as zeros

See Also:
Constant Field Values

relation

public java.util.TreeMap<java.lang.Integer,java.lang.Double> relation
Holds DiagramID - Coefficient pairs


relationID

private java.lang.String relationID
Relation ID


serialVersionUID

public static final long serialVersionUID
Serialization Version UID

See Also:
Constant Field Values
Constructor Detail

Relation

public Relation()
Constructs an instance of the relation

Method Detail

putEntry

public void putEntry(java.lang.Integer diagID,
                     double coef)
Adds a diagram with a coefficient to the relation

Parameters:
diagID - diagram ID
coef - diagram coefficient

nonEmpty

public boolean nonEmpty()
Tells whether there are any terms in the relations

Returns:
true, if the relation is not empty; false otherwise.

size

public int size()
Tells how many terms there are in this relation

Returns:
number of entries in the relation

equals_ex

public boolean equals_ex(Relation r)
Compares this relation to another relation

Parameters:
r - another relation
Returns:
true, if both relation have exactly the same terms

equals

public boolean equals(Relation r)

compareTo

public int compareTo(Relation r)
Compares this relation to another via String ID's

Specified by:
compareTo in interface java.lang.Comparable<Relation>

setID

public void setID()
Sets the relation ID string


ID

public java.lang.String ID()
Returns relation ID

Returns:
relation ID

isZero

public static boolean isZero(double d)
Tells if a double is "zero", i.e. less than epsilon

Parameters:
d - double to check
Returns:
true, if |d|

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

coefToString

public static java.lang.String coefToString(double D)
Returns a string representation of a coefficient

Parameters:
D - coefficient
Returns:
String representation of the coefficient