Android
java.util
public interface

java.util.Set<E>

java.util.Set<E> Collection<E>

Set is a collection which does not allow duplicate elements.

Known Indirect Subclasses

Summary

Public Methods

          boolean  add(E object)
Adds the specified object to this Set.
          boolean  addAll(Collection<? extends E> collection)
Adds the objects in the specified Collection which do not exist in this Set.
          void  clear()
Removes all elements from this Set, leaving it empty.
          boolean  contains(Object object)
Searches this Set for the specified object.
          boolean  containsAll(Collection<?> collection)
Searches this Set for all objects in the specified Collection.
          boolean  equals(Object object)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
          int  hashCode()
Returns an integer hash code for the receiver.
          boolean  isEmpty()
Returns if this Set has no elements, a size of zero.
          Iterator<E>  iterator()
Returns an Iterator on the elements of this Set.
          boolean  remove(Object object)
Removes any occurrence of the specified object from this Set.
          boolean  removeAll(Collection<?> collection)
Removes all objects in the specified Collection from this Set.
          boolean  retainAll(Collection<?> collection)
Removes all objects from this Set that are not contained in the specified Collection.
          int  size()
Returns the number of elements in this Set.
        <T>  T[]  toArray(T[] array)
Returns an array containing all elements contained in this Set.
          Object[]  toArray()
Returns an array containing all elements contained in this Set.
Methods inherited from interface java.lang.Iterable
Methods inherited from interface java.util.Collection

Details

Public Methods

public boolean add(E object)

Adds the specified object to this Set. The Set is not modified if it already contains the object.

Parameters

object the object to add

Returns

  • true if this Set is modified, false otherwise

Throws

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

public boolean addAll(Collection<? extends E> collection)

Adds the objects in the specified Collection which do not exist in this Set.

Parameters

collection the Collection of objects

Returns

  • true if this Set is modified, false otherwise

Throws

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

public void clear()

Removes all elements from this Set, leaving it empty.

Throws

UnsupportedOperationException when removing from this Set is not supported

See Also

public boolean contains(Object object)

Searches this Set for the specified object.

Parameters

object the object to search for

Returns

  • true if object is an element of this Set, false otherwise

public boolean containsAll(Collection<?> collection)

Searches this Set for all objects in the specified Collection.

Parameters

collection the Collection of objects

Returns

  • true if all objects in the specified Collection are elements of this Set, false otherwise

public boolean equals(Object object)

Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.

Parameters

object Object the object to compare with this object.

Returns

  • boolean true if the object is the same as this object false if it is different from this object.

See Also

public int hashCode()

Returns an integer hash code for the receiver. Objects which are equal answer the same value for this method.

Returns

  • the receiver's hash

See Also

public boolean isEmpty()

Returns if this Set has no elements, a size of zero.

Returns

  • true if this Set has no elements, false otherwise

See Also

public Iterator<E> iterator()

Returns an Iterator on the elements of this Set.

Returns

  • an Iterator on the elements of this Set

See Also

public boolean remove(Object object)

Removes any occurrence of the specified object from this Set.

Parameters

object the object to remove

Returns

  • true if this Set is modified, false otherwise

Throws

UnsupportedOperationException when removing from this Set is not supported

public boolean removeAll(Collection<?> collection)

Removes all objects in the specified Collection from this Set.

Parameters

collection the Collection of objects to remove

Returns

  • true if this Set is modified, false otherwise

Throws

UnsupportedOperationException when removing from this Set is not supported

public boolean retainAll(Collection<?> collection)

Removes all objects from this Set that are not contained in the specified Collection.

Parameters

collection the Collection of objects to retain

Returns

  • true if this Set is modified, false otherwise

Throws

UnsupportedOperationException when removing from this Set is not supported

public int size()

Returns the number of elements in this Set.

Returns

  • the number of elements 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.

Parameters

array the array

Returns

  • an array of the elements from this Set

Throws

ArrayStoreException when the type of an element in this Set cannot be stored in the type of the specified array

public Object[] toArray()

Returns an array containing all elements contained in this Set.

Returns

  • an array of the elements from this Set
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56