|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractSet<E>
org.geotools.util.DisjointSet<E>
E
- The type of elements in this set.public class DisjointSet<E>
A set which is disjoint from others DisjointSet
s. Two sets are
disjoint (or mutually exclusive) if their intersection is the empty
set. Adding an element to a DisjointSet
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<E> disjointSet)
Construct a new set mutually exclusive with the specified set. |
Method Summary | ||
---|---|---|
boolean |
add(E element)
Ensures that this collection contains the specified element. |
|
boolean |
addAll(java.util.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. |
|
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<E> |
getTrash()
Returns the trash set, or null if there is none. |
|
int |
hashCode()
Returns an hash value for this set. |
|
java.util.Iterator<E> |
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. |
|
|
toArray(T[] 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<E> 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<E> getTrash()
null
if there is none.
The trash set receive all elements removed from this set.
null
if none.public int size()
size
in interface java.util.Collection<E>
size
in interface java.util.Set<E>
size
in class java.util.AbstractCollection<E>
public boolean contains(java.lang.Object element)
true
if this set contains the specified element.
contains
in interface java.util.Collection<E>
contains
in interface java.util.Set<E>
contains
in class java.util.AbstractCollection<E>
element
- Object to be checked for containment in this set.
true
if this set contains the specified element.public boolean add(E element)
add
in interface java.util.Collection<E>
add
in interface java.util.Set<E>
add
in class java.util.AbstractCollection<E>
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.
remove
in interface java.util.Collection<E>
remove
in interface java.util.Set<E>
remove
in class java.util.AbstractCollection<E>
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.
containsAll
in interface java.util.Collection<E>
containsAll
in interface java.util.Set<E>
containsAll
in class java.util.AbstractCollection<E>
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<? extends E> c)
addAll
in interface java.util.Collection<E>
addAll
in interface java.util.Set<E>
addAll
in class java.util.AbstractCollection<E>
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.
removeAll
in interface java.util.Collection<E>
removeAll
in interface java.util.Set<E>
removeAll
in class java.util.AbstractSet<E>
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.
retainAll
in interface java.util.Collection<E>
retainAll
in interface java.util.Set<E>
retainAll
in class java.util.AbstractCollection<E>
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.
clear
in interface java.util.Collection<E>
clear
in interface java.util.Set<E>
clear
in class java.util.AbstractCollection<E>
public java.util.Iterator<E> iterator()
iterator
in interface java.lang.Iterable<E>
iterator
in interface java.util.Collection<E>
iterator
in interface java.util.Set<E>
iterator
in class java.util.AbstractCollection<E>
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<E>
toArray
in interface java.util.Set<E>
toArray
in class java.util.AbstractCollection<E>
public <T> T[] toArray(T[] a)
toArray
in interface java.util.Collection<E>
toArray
in interface java.util.Set<E>
toArray
in class java.util.AbstractCollection<E>
T
- The type of elements in the array.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()
toString
in class java.util.AbstractCollection<E>
public int hashCode()
hashCode
in interface java.util.Collection<E>
hashCode
in interface java.util.Set<E>
hashCode
in class java.util.AbstractSet<E>
public boolean equals(java.lang.Object set)
equals
in interface java.util.Collection<E>
equals
in interface java.util.Set<E>
equals
in class java.util.AbstractSet<E>
set
- The object to compare with this set for equality.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |