java.util.Set<E> |
![]() |
A Set
is a data structure which does not allow duplicate elements.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract boolean |
add(E object)
Adds the specified object to this set.
| ||||||||||
abstract boolean |
addAll(Collection<? extends E> collection)
Adds the objects in the specified collection which do not exist yet in this
set.
| ||||||||||
abstract void |
clear()
Removes all elements from this set, leaving it empty.
| ||||||||||
abstract boolean |
contains(Object object)
Searches this set for the specified object.
| ||||||||||
abstract boolean |
containsAll(Collection<?> collection)
Searches this set for all objects in the specified collection.
| ||||||||||
abstract boolean |
equals(Object object)
Compares the specified object to this set, and returns true if they represent
the same object using a class specific comparison.
| ||||||||||
abstract int |
hashCode()
Returns the hash code for this set.
| ||||||||||
abstract boolean |
isEmpty()
Returns true if this set has no elements.
| ||||||||||
abstract Iterator<E> |
iterator()
Returns an iterator on the elements of this set.
| ||||||||||
abstract boolean |
remove(Object object)
Removes the specified object from this set.
| ||||||||||
abstract boolean |
removeAll(Collection<?> collection)
Removes all objects in the specified collection from this set.
| ||||||||||
abstract boolean |
retainAll(Collection<?> collection)
Removes all objects from this set that are not contained in the specified
collection.
| ||||||||||
abstract int |
size()
Returns the number of elements in this set.
| ||||||||||
abstract Object[] |
toArray()
Returns an array containing all elements contained in this set.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
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.