|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.hedgehog.HObject
com.hedgehog.utility.IntegerSet
public class IntegerSet
Title: IntegerSet - set specifically for integers.
Description: Stores a set of integers.
This class is identical to Set except that all comparisons are performed on integer values and not object references.
Useful for comparing integer IDs in class ID.
Copyright: Copyright (c) Hedgehog Software 2007-2009.
Company: Hedgehog Software.
HSet| Field Summary | |
|---|---|
protected java.util.HashSet<HInteger> |
mSet
Set of HInteger elements. |
| Fields inherited from class com.hedgehog.HObject |
|---|
mID, mName |
| Constructor Summary | |
|---|---|
IntegerSet()
Constructor. |
|
IntegerSet(java.util.HashSet<HInteger> elements)
Constructor. |
|
IntegerSet(HInteger element)
Constructor. |
|
IntegerSet(int element)
Constructor. |
|
IntegerSet(int[] elements)
Constructor. |
|
IntegerSet(IntegerSet object)
Copy constructor. |
|
IntegerSet(java.util.Vector<HInteger> elements)
Constructor. |
|
| Method Summary | |
|---|---|
boolean |
add(HInteger element)
Adds the specified ID, provided it is not already a member. |
boolean |
add(int element)
Adds the specified ID, provided it is not already a member. |
IntegerSet |
difference(IntegerSet s)
Returns the difference A-B: the set containing all elements that are in A but not in B. |
void |
differenceFrom(IntegerSet s)
Difference A-B: the set containing all elements that are in A (this set) but not in B (s). |
java.util.HashSet<HInteger> |
getElements()
Returns the set elements. |
IntegerSet |
intersection(IntegerSet s)
Returns the intersection A&B: the set containing all elements that are both in A and B. |
void |
intersectionWith(IntegerSet s)
Intersection A&B: the set containing all elements that are both in A and B. |
boolean |
isEmpty()
Tests whether or not this set is empty. |
boolean |
isMember(HInteger element)
Tests whether or not the specified HInteger object is an element of this set. |
boolean |
isMember(int element)
Tests whether or not the specified element is a member of this set. |
int |
numberElements()
Returns the number of set elements. |
boolean |
remove(int element)
Removes the specified |
void |
removeAll()
Removes all elements from this set. |
int |
representativeElement()
Returns a representative element of this set; ie the first element. |
boolean |
sameSet(IntegerSet s)
Tests whether or not the specified set is identical to this set. |
void |
setElements(java.util.HashSet<HInteger> elements)
Sets the set elements. |
int |
size()
Equivalent to numberElements(), in that it returns the size of this set. |
boolean |
subsetOft(IntegerSet s)
Tests whether or not the specified set is a subset of this set. |
IntegerSet |
symmetricDifference(IntegerSet s)
Returns the symmetric difference; A^B: the union of A-B and B-A. |
int[] |
toArray()
Converts this set o a 1D Java array. |
java.lang.String |
toString()
Returns a String representation of a Set object. |
IntegerSet |
union(IntegerSet s)
Returns the uunion A|B: the set containing all elements in A and B (without duplication). |
void |
unionWith(IntegerSet s)
Union A|B: the set containing all elements in A and B (without duplication). |
| Methods inherited from class com.hedgehog.HObject |
|---|
clone, compare, compareTo, copy, equals, getID, getName, hashCode, hasID, hasName, setID, setName |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.util.HashSet<HInteger> mSet
| Constructor Detail |
|---|
public IntegerSet()
public IntegerSet(int element)
element - Set element.public IntegerSet(HInteger element)
element - Set element.public IntegerSet(java.util.HashSet<HInteger> elements)
elements - Hash set of elements.public IntegerSet(java.util.Vector<HInteger> elements)
elements - Vector of elements.public IntegerSet(int[] elements)
elements - Array of elements.public IntegerSet(IntegerSet object)
object - Object to copy.| Method Detail |
|---|
public java.util.HashSet<HInteger> getElements()
public void setElements(java.util.HashSet<HInteger> elements)
elements - New set elements.public boolean add(int element)
element - Element to add.
public boolean add(HInteger element)
element - Element to add.
public boolean remove(int element)
element - Element to remove.
public void removeAll()
public boolean isMember(int element)
element - Element to test.
public boolean isMember(HInteger element)
element - Object element to test.
public boolean isEmpty()
public int numberElements()
public int size()
public void differenceFrom(IntegerSet s)
s - Other set B.public void intersectionWith(IntegerSet s)
s - Other set B.public boolean subsetOft(IntegerSet s)
s - Subset.
public boolean sameSet(IntegerSet s)
s - Other set.
public int representativeElement()
throws InvalidObjectException
InvalidObjectException - Thrown if mSet is null or empty.public void unionWith(IntegerSet s)
s - Other set.public IntegerSet union(IntegerSet s)
s - Other set.
public IntegerSet intersection(IntegerSet s)
s - Other set.
public IntegerSet difference(IntegerSet s)
s - Other set.
public IntegerSet symmetricDifference(IntegerSet s)
s - Other set.
public java.lang.String toString()
toString in class java.lang.Objectpublic int[] toArray()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||