|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.util.AbstractCollection
java.util.AbstractSet
java.util.TreeSet
fi.joensuu.cs.tra.Set
fi.joensuu.cs.tra.Set extends java.util.TreeSet with comparison methods.
TreeSet,
TreeMap,
Serialized Form| Constructor Summary | |
|---|---|
Set()
Constructs a new, empty set, sorted according to the elements' natural order. |
|
Set(Collection<? extends E> c)
Constructs a new set containing the elements in the specified collection, sorted according to the elements' natural order. |
|
Set(Comparator<? super E> c)
Constructs a new, empty set, sorted according to the specified comparator. |
|
Set(SortedSet<E> s)
Constructs a new set containing the same elements as the specified sorted set, sorted according to the same ordering. |
|
| Method Summary | |
|---|---|
boolean |
add(E o)
Adds the specified element to this set if it is not already present. |
boolean |
addAll(Collection<? extends E> c)
Adds all of the elements in the specified collection to this set. |
void |
clear()
Removes all of the elements from this set. |
Object |
clone()
Returns a shallow copy of this TreeSet instance. |
Comparator<? super E> |
comparator()
Returns the comparator used to order this sorted set, or null if this tree set uses its elements natural ordering. |
boolean |
contains(Object o)
Returns true if this set contains the specified element. |
Set<E> |
difference(Collection<? extends E> c)
Returns the difference of this Set and the specified Collection. |
boolean |
equals(Collection<? extends E> c)
Checks if this Set and the specified Collection contain
the same elements. |
E |
first()
Returns the first (lowest) element currently in this sorted set. |
SortedSet<E> |
headSet(E toElement)
Returns a view of the portion of this set whose elements are strictly less than toElement. |
Set<E> |
intersection(Collection<? extends E> c)
Returns the intersection of this Set and the specified Collection. |
boolean |
isEmpty()
Returns true if this set contains no elements. |
Iterator<E> |
iterator()
Returns an iterator over the elements in this set. |
E |
last()
Returns the last (highest) element currently in this sorted set. |
boolean |
remove(Object o)
Removes the specified element from this set if it is present. |
int |
size()
Returns the number of elements in this set (its cardinality). |
SortedSet<E> |
subSet(E fromElement,
E toElement)
Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive. |
SortedSet<E> |
tailSet(E fromElement)
Returns a view of the portion of this set whose elements are greater than or equal to fromElement. |
Set<E> |
union(Collection<? extends E> c)
Returns the union of this Set and the specified Collection. |
| Methods inherited from class java.util.AbstractSet |
|---|
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
|---|
containsAll, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
|---|
containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray |
| Constructor Detail |
|---|
public Set()
public Set(Collection<? extends E> c)
public Set(Comparator<? super E> c)
public Set(SortedSet<E> s)
| Method Detail |
|---|
public boolean add(E o)
java.util.TreeSet
add in interface Setadd in class TreeSeto - element to be added to this set.
public boolean addAll(Collection<? extends E> c)
java.util.TreeSet
addAll in interface SetaddAll in class TreeSetc - elements to be added
AbstractCollection.add(Object)public void clear()
java.util.TreeSet
clear in interface Setclear in class TreeSetpublic Object clone()
java.util.TreeSet
clone in class TreeSetCloneablepublic Comparator<? super E> comparator()
java.util.TreeSet
comparator in interface SortedSetcomparator in class TreeSetpublic boolean contains(Object o)
java.util.TreeSet
contains in interface Setcontains in class TreeSeto - the object to be checked for containment in this set.
public E first()
java.util.TreeSet
first in interface SortedSetfirst in class TreeSetpublic SortedSet<E> headSet(E toElement)
java.util.TreeSetThe sorted set returned by this method will throw an IllegalArgumentException if the user attempts to insert an element greater than or equal to toElement.
Note: this method always returns a view that does not contain its (high) endpoint. If you need a view that does contain this endpoint, and the element type allows for calculation of the successor of a specified value, merely request a headSet bounded by successor(highEndpoint). For example, suppose that s is a sorted set of strings. The following idiom obtains a view containing all of the strings in s that are less than or equal to high:
SortedSet head = s.headSet(high+"\0");
headSet in interface SortedSetheadSet in class TreeSettoElement - high endpoint (exclusive) of the headSet.
public boolean isEmpty()
java.util.TreeSet
isEmpty in interface SetisEmpty in class TreeSetpublic Iterator<E> iterator()
java.util.TreeSet
iterator in interface Setiterator in class TreeSetpublic E last()
java.util.TreeSet
last in interface SortedSetlast in class TreeSetpublic boolean remove(Object o)
java.util.TreeSet
remove in interface Setremove in class TreeSeto - object to be removed from this set, if present.
public int size()
java.util.TreeSet
size in interface Setsize in class TreeSet
public SortedSet<E> subSet(E fromElement,
E toElement)
java.util.TreeSetThe sorted set returned by this method will throw an IllegalArgumentException if the user attempts to insert an element outside the specified range.
Note: this method always returns a half-open range (which includes its low endpoint but not its high endpoint). If you need a closed range (which includes both endpoints), and the element type allows for calculation of the successor of a specified value, merely request the subrange from lowEndpoint to successor(highEndpoint). For example, suppose that s is a sorted set of strings. The following idiom obtains a view containing all of the strings in s from low to high, inclusive:
SortedSet sub = s.subSet(low, high+"\0");
A similar technique can be used to generate an open range (which
contains neither endpoint). The following idiom obtains a view
containing all of the strings in s from low to
high, exclusive:
SortedSet sub = s.subSet(low+"\0", high);
subSet in interface SortedSetsubSet in class TreeSetfromElement - low endpoint (inclusive) of the subSet.toElement - high endpoint (exclusive) of the subSet.
public SortedSet<E> tailSet(E fromElement)
java.util.TreeSetThe sorted set returned by this method will throw an IllegalArgumentException if the user attempts to insert an element less than fromElement. Note: this method always returns a view that contains its (low) endpoint. If you need a view that does not contain this endpoint, and the element type allows for calculation of the successor of a specified value, merely request a tailSet bounded by successor(lowEndpoint). For example, suppose that s is a sorted set of strings. The following idiom obtains a view containing all of the strings in s that are strictly greater than low:
SortedSet tail = s.tailSet(low+"\0");
tailSet in interface SortedSettailSet in class TreeSetfromElement - low endpoint (inclusive) of the tailSet.
public Set<E> union(Collection<? extends E> c)
Collection.
c - the Collection to combine this Set with.
Collection.public Set<E> intersection(Collection<? extends E> c)
Collection.
c - the Collection to intersect this Set with.
Collection.public Set<E> difference(Collection<? extends E> c)
Collection.
c - the Collection to subtract from this Set.
Collection.public boolean equals(Collection<? extends E> c)
Collection contain
the same elements.
c - the Collection to compare this Set with.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||