java.util.Set<E> |
Known Indirect Subclasses
AbstractSet<E>,
ArraySet<E>,
ConcurrentSkipListSet<E>,
CopyOnWriteArraySet<E>,
EnumSet<E extends Enum<E>>,
HashSet<E>,
LinkedHashSet<E>,
NavigableSet<E>,
SortedSet<E>,
TreeSet<E>
|
A Set
is a data structure which does not allow duplicate elements.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds the specified object to this set.
| |||||||||||
Adds the objects in the specified collection which do not exist yet in
this set.
| |||||||||||
Removes all elements from this set, leaving it empty.
| |||||||||||
Searches this set for the specified object.
| |||||||||||
Searches this set for all objects in the specified collection.
| |||||||||||
Compares the specified object to this set, and returns true if they
represent the same object using a class specific comparison.
| |||||||||||
Returns the hash code for this set.
| |||||||||||
Returns true if this set has no elements.
| |||||||||||
Returns an iterator on the elements of this set.
| |||||||||||
Removes the specified object from this set.
| |||||||||||
Removes all objects in the specified collection from this set.
| |||||||||||
Removes all objects from this set that are not contained in the specified
collection.
| |||||||||||
Returns the number of elements in this set.
| |||||||||||
Returns an array containing all elements contained in this set.
| |||||||||||
Returns an array containing all elements contained in this set.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
java.util.Collection
| |||||||||||
From interface
java.lang.Iterable
|
Adds the specified object to this set. The set is not modified if it already contains the object.
object | the object to add. |
---|
true
if this set is modified, false
otherwise.UnsupportedOperationException | when adding to this set is not supported. |
---|---|
ClassCastException | when the class of the object is inappropriate for this set. |
IllegalArgumentException | when the object cannot be added to this set. |
Adds the objects in the specified collection which do not exist yet in this set.
collection | the collection of objects. |
---|
true
if this set is modified, false
otherwise.UnsupportedOperationException | when adding to this set is not supported. |
---|---|
ClassCastException | when the class of an object is inappropriate for this set. |
IllegalArgumentException | when an object cannot be added to this set. |
Removes all elements from this set, leaving it empty.
UnsupportedOperationException | when removing from this set is not supported. |
---|
Searches this set for the specified object.
object | the object to search for. |
---|
true
if object is an element of this set, false
otherwise.
Searches this set for all objects in the specified collection.
collection | the collection of objects. |
---|
true
if all objects in the specified collection are
elements of this set, false
otherwise.
Compares the specified object to this set, and returns true if they represent the same object using a class specific comparison. Equality for a set means that both sets have the same size and the same elements.
object | the object to compare with this object. |
---|
true
if the object is the same as this object,
and false
if it is different from this object.Returns the hash code for this set. Two set which are equal must return the same value.
Returns true if this set has no elements.
true
if this set has no elements, false
otherwise.Returns an iterator on the elements of this set. The elements are unordered.
Removes the specified object from this set.
object | the object to remove. |
---|
true
if this set was modified, false
otherwise.UnsupportedOperationException | when removing from this set is not supported. |
---|
Removes all objects in the specified collection from this set.
collection | the collection of objects to remove. |
---|
true
if this set was modified, false
otherwise.UnsupportedOperationException | when removing from this set is not supported. |
---|
Removes all objects from this set that are not contained in the specified collection.
collection | the collection of objects to retain. |
---|
true
if this set was modified, false
otherwise.UnsupportedOperationException | when removing from this set is not supported. |
---|
Returns the number of elements in this set.
Returns an array containing all elements contained in this set. If the specified array is large enough to hold the elements, the specified array is used, otherwise an array of the same type is created. If the specified array is used and is larger than this set, the array element following the collection elements is set to null.
array | the array. |
---|
ArrayStoreException | when the type of an element in this set cannot be stored in the type of the specified array. |
---|
Returns an array containing all elements contained in this set.