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

java.lang.Object
  extended by java.util.AbstractCollection<K>
      extended by it.unimi.dsi.fastutil.objects.AbstractObjectCollection<K>
          extended by it.unimi.dsi.fastutil.objects.AbstractObjectList<K>
              extended by it.unimi.dsi.fastutil.objects.ObjectLists.Singleton<K>
All Implemented Interfaces:
ObjectCollection<K>, ObjectIterable<K>, ObjectList<K>, Stack<K>, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<java.util.List<? extends K>>, java.lang.Iterable<K>, java.util.Collection<K>, java.util.List<K>
Enclosing class:
ObjectLists

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

An immutable class representing a type-specific singleton list.

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

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class it.unimi.dsi.fastutil.objects.AbstractObjectList
AbstractObjectList.ObjectSubList<K>
 
Method Summary
 boolean addAll(java.util.Collection<? extends K> c)
          Delegates to a more generic method.
 boolean addAll(int i, java.util.Collection<? extends K> c)
           
 void clear()
           
 java.lang.Object clone()
           
 boolean contains(java.lang.Object k)
           
 K get(int i)
           
 ObjectListIterator<K> iterator()
          Returns a type-specific iterator on the elements of this collection.
 ObjectListIterator<K> listIterator()
          Returns a type-specific list iterator on the list.
 ObjectListIterator<K> listIterator(int i)
          Returns a type-specific list iterator on the list starting at a given index.
 K remove(int i)
           
 boolean remove(java.lang.Object k)
           
 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()
           
 void size(int size)
          Sets the size of this list.
 ObjectList<K> subList(int from, int to)
          Returns a type-specific view of the portion of this list from the index from, inclusive, to the index to, exclusive.
 java.lang.Object[] toArray()
           
 
Methods inherited from class it.unimi.dsi.fastutil.objects.AbstractObjectList
add, add, addElements, addElements, compareTo, equals, getElements, hashCode, indexOf, lastIndexOf, objectListIterator, objectListIterator, objectSubList, peek, pop, push, removeElements, set, top, toString
 
Methods inherited from class it.unimi.dsi.fastutil.objects.AbstractObjectCollection
containsAll, isEmpty, objectIterator, toArray
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, isEmpty, toArray
 
Methods inherited from interface it.unimi.dsi.fastutil.objects.ObjectCollection
objectIterator, toArray
 
Methods inherited from interface it.unimi.dsi.fastutil.Stack
isEmpty
 

Method Detail

get

public K get(int i)
Specified by:
get in interface java.util.List<K>

remove

public K remove(int i)
Specified by:
remove in interface java.util.List<K>
Overrides:
remove in class AbstractObjectList<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.List<K>
Overrides:
contains in class AbstractObjectList<K>

addAll

public boolean addAll(java.util.Collection<? extends K> c)
Description copied from class: AbstractObjectList
Delegates to a more generic method.

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

addAll

public boolean addAll(int i,
                      java.util.Collection<? extends K> c)
Specified by:
addAll in interface java.util.List<K>
Overrides:
addAll in class AbstractObjectList<K>

removeAll

public boolean removeAll(java.util.Collection<?> c)
Description copied from class: AbstractObjectCollection
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.List<K>
Overrides:
removeAll in class AbstractObjectCollection<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: AbstractObjectCollection
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.List<K>
Overrides:
retainAll in class AbstractObjectCollection<K>
Parameters:
c - a collection.
Returns:
true if this collection changed as a result of the call.

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<K>
Specified by:
toArray in interface java.util.List<K>
Overrides:
toArray in class AbstractObjectCollection<K>

listIterator

public ObjectListIterator<K> listIterator()
Description copied from interface: ObjectList
Returns a type-specific list iterator on the list.

Specified by:
listIterator in interface ObjectList<K>
Specified by:
listIterator in interface java.util.List<K>
Overrides:
listIterator in class AbstractObjectList<K>
See Also:
List.listIterator()

iterator

public ObjectListIterator<K> iterator()
Description copied from interface: ObjectCollection
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 ObjectCollection<K>
Specified by:
iterator in interface ObjectIterable<K>
Specified by:
iterator in interface ObjectList<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.List<K>
Overrides:
iterator in class AbstractObjectList<K>
Returns:
a type-specific iterator on the elements of this collection.

listIterator

public ObjectListIterator<K> listIterator(int i)
Description copied from interface: ObjectList
Returns a type-specific list iterator on the list starting at a given index.

Specified by:
listIterator in interface ObjectList<K>
Specified by:
listIterator in interface java.util.List<K>
Overrides:
listIterator in class AbstractObjectList<K>
See Also:
List.listIterator(int)

subList

public ObjectList<K> subList(int from,
                             int to)
Description copied from interface: ObjectList
Returns a type-specific view of the portion of this list from the index from, inclusive, to the index to, exclusive.

Note that this specification strengthens the one given in List.subList(int,int).

Specified by:
subList in interface ObjectList<K>
Specified by:
subList in interface java.util.List<K>
Overrides:
subList in class AbstractObjectList<K>
See Also:
List.subList(int,int)

size

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

size

public void size(int size)
Description copied from interface: ObjectList
Sets the size of this list.

If the specified size is smaller than the current size, the last elements are discarded. Otherwise, they are filled with 0/null/false.

Specified by:
size in interface ObjectList<K>
Overrides:
size in class AbstractObjectList<K>
Parameters:
size - the new size.

clear

public void clear()
Specified by:
clear in interface java.util.Collection<K>
Specified by:
clear in interface java.util.List<K>
Overrides:
clear in class java.util.AbstractCollection<K>

clone

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

remove

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