Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.util
Class Collections.SingletonSet  view Collections.SingletonSet download Collections.SingletonSet.java

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractSet
          extended byjava.util.Collections.SingletonSet
All Implemented Interfaces:
Collection, java.lang.Iterable, java.io.Serializable, Set
Enclosing class:
Collections

private static final class Collections.SingletonSet
extends AbstractSet
implements java.io.Serializable

The implementation of Collections.singleton(Object) 55 . This class name is required for compatibility with Sun's JDK serializability.


Field Summary
(package private)  java.lang.Object element
          The single element; package visible for use in nested class.
private static long serialVersionUID
          Compatible with JDK 1.4.
 
Constructor Summary
(package private) Collections.SingletonSet(java.lang.Object o)
          Construct a singleton.
 
Method Summary
 boolean contains(java.lang.Object o)
          The set only contains one element.
 boolean containsAll(Collection c)
          This is true if the other collection only contains the element.
 int hashCode()
          The hash is just that of the element.
 Iterator iterator()
          Returns an iterator over the lone element.
 int size()
          The size: always 1!
 java.lang.Object[] toArray()
          Returning an array is simple.
 java.lang.String toString()
          Obvious string.
 
Methods inherited from class java.util.AbstractSet
equals, removeAll
 
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, equals, hashCode, isEmpty, remove, removeAllInternal, retainAll, retainAllInternal, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
add, addAll, clear, isEmpty, remove, retainAll, toArray
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Compatible with JDK 1.4.

See Also:
Constant Field Values

element

final java.lang.Object element
The single element; package visible for use in nested class.

Constructor Detail

Collections.SingletonSet

Collections.SingletonSet(java.lang.Object o)
Construct a singleton.

Method Detail

size

public int size()
The size: always 1!

Specified by:
size in interface Set
Specified by:
size in class AbstractCollection

iterator

public Iterator iterator()
Returns an iterator over the lone element.

Specified by:
iterator in interface Set
Specified by:
iterator in class AbstractCollection

contains

public boolean contains(java.lang.Object o)
The set only contains one element.

Specified by:
contains in interface Set
Overrides:
contains in class AbstractCollection

containsAll

public boolean containsAll(Collection c)
This is true if the other collection only contains the element.

Specified by:
containsAll in interface Set
Overrides:
containsAll in class AbstractCollection

hashCode

public int hashCode()
The hash is just that of the element.

Specified by:
hashCode in interface Set
Overrides:
hashCode in class AbstractSet

toArray

public java.lang.Object[] toArray()
Returning an array is simple.

Specified by:
toArray in interface Set
Overrides:
toArray in class AbstractCollection

toString

public java.lang.String toString()
Obvious string.

Overrides:
toString in class AbstractCollection