|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ptolemy.actor.util.TotallyOrderedSet
public class TotallyOrderedSet
An object of this class is a totally ordered set with an increasing order. The order between any two elements in the set can be checked by calling the compare() method of a comparator associated with this object. An element, a, in this set is said to precede another one, b, if compare(a, b) returns -1.
The set does not contain repeated elements, which means comparing any two elements in this set never returns 0.
Green (hyzheng) |
Green (hyzheng) |
Field Summary | |
---|---|
private java.util.Comparator |
_comparator
The comparator for the order. |
private java.util.LinkedList |
_set
The set. |
Constructor Summary | |
---|---|
TotallyOrderedSet(java.util.Comparator comparator)
Construct a set with the given comparator. |
Method Summary | |
---|---|
java.lang.Object |
at(int index)
Return the element with the given index. |
void |
clear()
Clear the set by removing all elements. |
boolean |
contains(java.lang.Object object)
Return true if the given element is contained in this set. |
java.util.List |
elementList()
Return a list of all the elements. |
java.util.Enumeration |
elements()
Deprecated. Use elementList() instead. |
java.lang.Object |
first()
Return the first element, ie. the smallest element. |
java.util.Comparator |
getComparator()
Return the comparator. |
int |
indexOf(java.lang.Object obj)
Return the index of the given object. |
void |
insert(java.lang.Object obj)
Insert the given element while keeping the set sorted. |
boolean |
isEmpty()
Return true if the set is empty. |
void |
removeAllLessThan(java.lang.Object obj)
Remove all the elements that are (strictly) less than the argument. |
java.lang.Object |
removeAt(int index)
Remove and return the element with the given index. |
java.lang.Object |
removeFirst()
Remove and return the first element, ie. the smallest element in the set. |
int |
size()
Return the size of the set. |
java.lang.Object |
take()
Deprecated. Use removeFirst() instead. |
java.lang.String |
toString()
Return a string that consists of the contents of the elements in the set. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final java.util.Comparator _comparator
private java.util.LinkedList _set
Constructor Detail |
---|
public TotallyOrderedSet(java.util.Comparator comparator)
comparator
- The Comparator with which to compare elements.
Note that the comparator cannot be changed after this TotallyOrderedSet
object is constructed.Comparator
Method Detail |
---|
public java.lang.Object at(int index)
index
- The index of the element to return.
public void clear()
public boolean contains(java.lang.Object object)
object
- The object to check for containment.
public java.util.List elementList()
public java.util.Enumeration elements()
public java.lang.Object first()
public java.util.Comparator getComparator()
public int indexOf(java.lang.Object obj)
obj
- The objec to get index for.
public void insert(java.lang.Object obj)
obj
- The element to be inserted.public boolean isEmpty()
public void removeAllLessThan(java.lang.Object obj)
obj
- The argument.public java.lang.Object removeAt(int index)
index
- The index of the element.
public java.lang.Object removeFirst()
public int size()
public java.lang.Object take()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |