|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection
java.util.AbstractSet
org.geotools.util.DisjointSet
A set which is disjoint from others DisjointSet
s. Two sets are
disjoint (or mutually exclusiveDisjointSet remove it from any other
mutually exclusive DisjointSet
. Optionnaly, DisjointSet
s
may also have a trash set receiving removed elements. The example below
creates 3 mutually exclusive sets with a trash:
Disjoint sets are thread-safe.DisjointSet set0 = new DisjointSet(true); // Used as the trash set. DisjointSet set1 = new DisjointSet(set0); DisjointSet set2 = new DisjointSet(set0);
Constructor Summary | |
DisjointSet()
Construct a initially empty set. |
|
DisjointSet(boolean hasTrash)
Construct a initially empty set with an optional trash set. |
|
DisjointSet(DisjointSet disjointSet)
Construct a new set mutually exclusive with the specified set. |
Method Summary | |
boolean |
add(java.lang.Object element)
Ensures that this collection contains the specified element. |
boolean |
addAll(java.util.Collection c)
Adds all of the elements in the specified collection to this set. |
void |
clear()
Removes all of the elements from this set. |
boolean |
contains(java.lang.Object element)
Returns true if this set contains the specified element. |
boolean |
containsAll(java.util.Collection c)
Returns true if this set contains
all of the elements in the specified collection. |
boolean |
equals(java.lang.Object set)
Compare this set with the specified object for equality. |
java.util.Set |
getTrash()
Returns the trash set, or null if there is none.
|
int |
hashCode()
Returns an hash value for this set. |
java.util.Iterator |
iterator()
Returns an iterator over the elements in this collection. |
boolean |
remove(java.lang.Object element)
Removes a single instance of the specified element from this set, if it is present. |
boolean |
removeAll(java.util.Collection c)
Removes from this set all of its elements that are contained in the specified collection. |
boolean |
retainAll(java.util.Collection c)
Retains only the elements in this set that are contained in the specified collection. |
int |
size()
Returns the number of elements in this set. |
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this collection. |
java.lang.Object[] |
toArray(java.lang.Object[] a)
Returns an array containing all of the elements in this collection. |
java.lang.String |
toString()
Returns a string representation of this set. |
Methods inherited from class java.util.AbstractCollection |
isEmpty |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Set |
isEmpty |
Constructor Detail |
public DisjointSet()
DisjointSet(DisjointSet)
constructor with this newly created
set as argument.
DisjointSet
s constructed using this constructor has no trash.
All remove operations on this set really remove all references to the
removed element, like a usual Set
. This is opposed to moving the
element to a "trash" set, which is allowed by the DisjointSet(true)
constructor.
public DisjointSet(boolean hasTrash)
DisjointSet(DisjointSet)
constructor with this
newly created set as argument.
hasTrash
- If true
, all remove operations
will add removed elements to a trash set (thus, really just moving the
element to the trash). If false
, there is no trash and this
constructor behave like the no-argument constructor.getTrash()
public DisjointSet(DisjointSet disjointSet)
disjointSet
will also be mutually exclusive with the
newly created set. If disjointSet
has a trash set, the newly created
set will use the same trash (i.e. all remove
operations will really
move the element to the trash set). Otherwise, the new DisjointSet
have no trash.
disjointSet
- The set to be disjoint from.Method Detail |
public java.util.Set getTrash()
null
if there is none.
The trash set receive all elements removed from this set.
public int size()
public boolean contains(java.lang.Object element)
true
if this set contains the specified element.
element
- Object to be checked for containment in this set.
true
if this set contains the specified element.public boolean add(java.lang.Object element)
element
- Element whose presence in this set is to be ensured.
true
if the set changed as a result of the call.public boolean remove(java.lang.Object element)
DisjointSet
has a trash set,
the removed element will be added to the trash set.
element
- Element to be removed from this set.
true
if the set changed as a result of the call.public boolean containsAll(java.util.Collection c)
true
if this set contains
all of the elements in the specified collection.
c
- collection to be checked for containment in this collection.
true
if this set contains all of the elements in
the specified collection.public boolean addAll(java.util.Collection c)
c
- collection whose elements are to be added to this set.
true
if this set changed as a result of the call.public boolean removeAll(java.util.Collection c)
DisjointSet
has
a trash set, all removed elements will be added to the trash set.
c
- elements to be removed from this set.
true
if this set changed as a result of the call.public boolean retainAll(java.util.Collection c)
DisjointSet
has a trash set, all removed
elements will be added to the trash set.
c
- elements to be retained in this collection.
true
if this collection changed as a result of the call.public void clear()
DisjointSet
has a trash set, all removed elements will be added to the trash set.
public java.util.Iterator iterator()
public java.lang.Object[] toArray()
public java.lang.Object[] toArray(java.lang.Object[] a)
a
- The array into which the elements of the set are to be
stored, if it is big enough; otherwise, a new array of
the same runtime type is allocated for this purpose.
public java.lang.String toString()
public int hashCode()
public boolean equals(java.lang.Object set)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |