|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.hedgehog.HObject
com.hedgehog.utility.TripleInteger
public class TripleInteger
Title: TripleInteger - a triple specifically for fundamental type int.
Description: Stores a triple of ints. Triple specifically for type int, since it is so frequently used it saves repeatedly having to work through HInteger.
Copyright: Copyright (c) Hedgehog Software 2007-2009.
Company: Hedgehog Software
| Field Summary | |
|---|---|
protected int |
mp
Triple value p. |
protected int |
mq
Triple value q. |
protected int |
mr
Triple value r. |
| Fields inherited from class com.hedgehog.HObject |
|---|
mID, mName |
| Constructor Summary | |
|---|---|
TripleInteger()
Default constructor. |
|
TripleInteger(int p,
int q,
int r)
Constructor. |
|
TripleInteger(int p,
int q,
int r,
boolean sortedIncreasing)
Constructor. |
|
TripleInteger(TripleInteger object)
Copy constructor. |
|
| Method Summary | |
|---|---|
int |
compare(java.lang.Object obj1,
java.lang.Object obj2)
Overrides the Comparator.compare() method. |
int |
compareTo(java.lang.Object obj)
Overrides the Comparable.compareTo() method. |
java.util.Vector<PairInteger> |
cyclicPairs()
Returns a vector of cyclic pairs; ie (p,q), (q,r) and (r,p). |
boolean |
equals(java.lang.Object object)
Compares the specified object to this object. |
int |
getP()
Returns value p. |
int |
getQ()
Returns value q. |
int |
getR()
Returns value r. |
int |
hashCode()
Returns the hash code for this triple; ie: |
int |
intermediateValue()
Returns the intermediate value. |
boolean |
isDecreasingSequence(boolean useEquality)
Tests whether or not this triple's values form a decreasing sequence. |
boolean |
isElement(int v)
Tests whether or not the specified value is an element of this triple. |
boolean |
isIncreasingSequence(boolean useEquality)
Tests whether or not this triple's values form an increasing sequence. |
boolean |
isSameSet(TripleInteger tri)
Tests whether or not the specified triple hasa the same integer set as this triple, even though the ordering may differ. |
boolean |
isSameTriple(int p,
int q,
int r)
Tests whether or not the specified triple values are identical to this triple. |
boolean |
isSameTriple(TripleInteger triple)
Tests whether or not the specified triple object has identical values to this triple. |
boolean |
isSameTripleValues()
Tests whether or not all values of this triple are equivalent. |
boolean |
isSorted(boolean increasingOrder)
Tests whether or not this triple's values are sorted. |
int |
maxValue()
Returns the maximum value. |
int |
minValue()
Returns the minimum value. |
int |
other(int v0,
int v1)
Returns the other triple value not equal to the specified triple values. |
java.util.Vector<HInteger> |
others(int v)
Returns the other triple values not equal to the specified triple value. |
void |
reverse()
Reverses the values of this triple (p,q,r) so that the triple becomes (r,q,p), noting that q remains unaltered. |
boolean |
sameCyclicSequence(TripleInteger triple,
boolean bothDirections)
Tests whether or not the specified triple has a cyclic sequence that matches this triple. |
void |
set(int new_p,
int new_q,
int new_r)
Sets all 3 values of this triple. |
void |
setP(int new_p)
Assigns a new value to p. |
void |
setQ(int new_q)
Assigns a new value to q. |
void |
setR(int new_r)
Assigns a new value to r. |
void |
sort(boolean increasingOrder)
Orders this triple in either an increasing or decreasing sequence. |
java.lang.String |
toString()
A String representation of this TripleInteger object. |
| Methods inherited from class com.hedgehog.HObject |
|---|
clone, copy, getID, getName, hasID, hasName, setID, setName |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected int mp
protected int mq
protected int mr
| Constructor Detail |
|---|
public TripleInteger()
public TripleInteger(int p,
int q,
int r)
p - Triple value p.q - Triple value q.r - Triple value r;
public TripleInteger(int p,
int q,
int r,
boolean sortedIncreasing)
p - Triple value p.q - Triple value q.r - Triple value r;sortedIncreasing - Specifies whether the triple is to be sorted in increasing (true) order or decreasing (false) order.public TripleInteger(TripleInteger object)
object - Object to copy.| Method Detail |
|---|
public int getP()
public int getQ()
public int getR()
public int compare(java.lang.Object obj1,
java.lang.Object obj2)
compare in interface java.util.Comparatorcompare in class HObjectobj1 - Object 1.obj2 - Object 2.
public int compareTo(java.lang.Object obj)
compareTo in interface java.lang.ComparablecompareTo in class HObjectobj - Object to compare against this object.
public boolean equals(java.lang.Object object)
equals in interface java.util.Comparatorequals in class HObjectobject - Object to compare against this object.
public int hashCode()
long bits = (long)mp;
bits ^= mq * 31;
bits ^= mr * 31;
long hash = bits ^ (bits>>32);
return (int)hash;
hashCode in class HObjectpublic java.lang.String toString()
toString in class java.lang.Objectpublic void setP(int new_p)
new_p - New p value.public void setQ(int new_q)
new_q - New q value.public void setR(int new_r)
new_r - New r value.
public void set(int new_p,
int new_q,
int new_r)
new_p - New p value.new_q - New q value.new_r - New r value.public void reverse()
public boolean sameCyclicSequence(TripleInteger triple,
boolean bothDirections)
triple - Triple to compare this triple.bothDirections - Specfies whether or not both directions of the specified triple are to be compared. If true then triple is
reversed and the cyclic comparison repeated.
public int minValue()
public int maxValue()
public int intermediateValue()
public void sort(boolean increasingOrder)
increasingOrder - Specifies whether the ordeing should be increasing (true) or decreasing (false).public boolean isSorted(boolean increasingOrder)
increasingOrder - Specifies whether the values to be tested in increasing (true) order or decreasing (false) order.
public java.util.Vector<PairInteger> cyclicPairs()
public int other(int v0,
int v1)
throws java.lang.IllegalArgumentException
v0 - Element value.v1 - Element value.
java.lang.IllegalArgumentException - Thrown if v0 or v1 is not an element value of this triple.
public java.util.Vector<HInteger> others(int v)
throws java.lang.IllegalArgumentException
v - Triple element value.
java.lang.IllegalArgumentException - Thrown if v is not an element value of this triple.public boolean isElement(int v)
v - Value to test.
public boolean isSameTriple(int p,
int q,
int r)
p - Triple value p.q - Triple value q.r - Triple value r.
public boolean isSameTriple(TripleInteger triple)
triple - Triple to compare.
public boolean isSameSet(TripleInteger tri)
tri - Other triple.
public boolean isSameTripleValues()
public boolean isIncreasingSequence(boolean useEquality)
useEquality - Specifies whether or not to use the >= operator or just > when comparing the values.
public boolean isDecreasingSequence(boolean useEquality)
useEquality - Specifies whether or not to use the <= operator or just < when comparing the values.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||