Save This Page
Home » apache-harmony-6.0-src-r917296-snapshot » java » util » [javadoc | source]
java.util
public interface: Set [javadoc | source]

All Implemented Interfaces:
    Collection

A {@code Set} is a data structure which does not allow duplicate elements.
Method from java.util.Set Summary:
add,   addAll,   clear,   contains,   containsAll,   equals,   hashCode,   isEmpty,   iterator,   remove,   removeAll,   retainAll,   size,   toArray,   toArray
Method from java.util.Set Detail:
 public boolean add(E object)
    Adds the specified object to this set. The set is not modified if it already contains the object.
 public boolean addAll(Collection<? extends E> collection)
    Adds the objects in the specified collection which do not exist yet in this set.
 public  void clear()
    Removes all elements from this set, leaving it empty.
 public boolean contains(Object object)
    Searches this set for the specified object.
 public boolean containsAll(Collection<?> collection)
    Searches this set for all objects in the specified collection.
 public 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. Equality for a set means that both sets have the same size and the same elements.
 public int hashCode()
    Returns the hash code for this set. Two set which are equal must return the same value.
 public boolean isEmpty()
    Returns true if this set has no elements.
 public Iterator<E> iterator()
    Returns an iterator on the elements of this set. The elements are unordered.
 public boolean remove(Object object)
    Removes the specified object from this set.
 public boolean removeAll(Collection<?> collection)
    Removes all objects in the specified collection from this set.
 public boolean retainAll(Collection<?> collection)
    Removes all objects from this set that are not contained in the specified collection.
 public int size()
    Returns the number of elements in this set.
 public Object[] toArray()
    Returns an array containing all elements contained in this set.
 public T[] toArray(T[] array)
    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.