it.unimi.dsi.fastutil.objects
Class ReferenceSets.Singleton<K>

java.lang.Object
  extended by java.util.AbstractCollection<K>
      extended by it.unimi.dsi.fastutil.objects.AbstractReferenceCollection<K>
          extended by it.unimi.dsi.fastutil.objects.AbstractReferenceSet<K>
              extended by it.unimi.dsi.fastutil.objects.ReferenceSets.Singleton<K>
All Implemented Interfaces:
ObjectIterable<K>, ReferenceCollection<K>, ReferenceSet<K>, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<K>, java.util.Collection<K>, java.util.Set<K>
Direct Known Subclasses:
ReferenceSortedSets.Singleton
Enclosing class:
ReferenceSets

public static class ReferenceSets.Singleton<K>
extends AbstractReferenceSet<K>
implements java.io.Serializable, java.lang.Cloneable

An immutable class representing a type-specific singleton set.

This class may be useful to implement your own in case you subclass a type-specific set.

See Also:
Serialized Form

Method Summary
 boolean add(K k)
           
 boolean addAll(java.util.Collection<? extends K> c)
          Adds all elements of the given collection to this collection.
 java.lang.Object clone()
           
 boolean contains(java.lang.Object k)
           
 ObjectListIterator<K> iterator()
          Returns a type-specific iterator on the elements of this collection.
 boolean removeAll(java.util.Collection<?> c)
          Remove from this collection all elements in the given collection.
 boolean retainAll(java.util.Collection<?> c)
          Retains in this collection only elements from the given collection.
 int size()
           
 
Methods inherited from class it.unimi.dsi.fastutil.objects.AbstractReferenceSet
equals, hashCode, remove
 
Methods inherited from class it.unimi.dsi.fastutil.objects.AbstractReferenceCollection
containsAll, isEmpty, objectIterator, toArray, toArray, toString
 
Methods inherited from class java.util.AbstractCollection
clear
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface it.unimi.dsi.fastutil.objects.ReferenceCollection
objectIterator, toArray
 
Methods inherited from interface java.util.Set
clear, containsAll, isEmpty, toArray, toArray
 

Method Detail

add

public boolean add(K k)
Specified by:
add in interface java.util.Collection<K>
Specified by:
add in interface java.util.Set<K>
Overrides:
add in class AbstractReferenceCollection<K>

contains

public boolean contains(java.lang.Object k)
Specified by:
contains in interface java.util.Collection<K>
Specified by:
contains in interface java.util.Set<K>
Overrides:
contains in class java.util.AbstractCollection<K>

addAll

public boolean addAll(java.util.Collection<? extends K> c)
Description copied from class: AbstractReferenceCollection
Adds all elements of the given collection to this collection.

Specified by:
addAll in interface java.util.Collection<K>
Specified by:
addAll in interface java.util.Set<K>
Overrides:
addAll in class AbstractReferenceCollection<K>
Parameters:
c - a collection.
Returns:
true if this collection changed as a result of the call.

removeAll

public boolean removeAll(java.util.Collection<?> c)
Description copied from class: AbstractReferenceCollection
Remove from this collection all elements in the given collection. If the collection is an instance of this class, it uses faster iterators.

Specified by:
removeAll in interface java.util.Collection<K>
Specified by:
removeAll in interface java.util.Set<K>
Overrides:
removeAll in class AbstractReferenceCollection<K>
Parameters:
c - a collection.
Returns:
true if this collection changed as a result of the call.

retainAll

public boolean retainAll(java.util.Collection<?> c)
Description copied from class: AbstractReferenceCollection
Retains in this collection only elements from the given collection.

Specified by:
retainAll in interface java.util.Collection<K>
Specified by:
retainAll in interface java.util.Set<K>
Overrides:
retainAll in class AbstractReferenceCollection<K>
Parameters:
c - a collection.
Returns:
true if this collection changed as a result of the call.

iterator

public ObjectListIterator<K> iterator()
Description copied from interface: ReferenceCollection
Returns a type-specific iterator on the elements of this collection.

Note that this specification strengthens the one given in Iterable.iterator(), which was already strengthened in the corresponding type-specific class, but was weakened by the fact that this interface extends Collection.

Specified by:
iterator in interface ObjectIterable<K>
Specified by:
iterator in interface ReferenceCollection<K>
Specified by:
iterator in interface ReferenceSet<K>
Specified by:
iterator in interface java.lang.Iterable<K>
Specified by:
iterator in interface java.util.Collection<K>
Specified by:
iterator in interface java.util.Set<K>
Specified by:
iterator in class AbstractReferenceSet<K>
Returns:
a type-specific iterator on the elements of this collection.

size

public int size()
Specified by:
size in interface java.util.Collection<K>
Specified by:
size in interface java.util.Set<K>
Specified by:
size in class java.util.AbstractCollection<K>

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object