public class TotallyOrderedSet
extends java.lang.Object
The set does not contain repeated elements, which means comparing any two elements in this set never returns 0.
Constructor and Description |
---|
TotallyOrderedSet(java.util.Comparator comparator)
Construct a set with the given comparator.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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
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()
@Deprecated public java.util.Enumeration elements()
public java.lang.Object first()
public java.util.Comparator getComparator()
public int indexOf(java.lang.Object obj)
obj
- The object 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()
@Deprecated public java.lang.Object take()
public java.lang.String toString()
toString
in class java.lang.Object