it.unimi.dsi.fastutil.shorts
Class ShortLists.Singleton

java.lang.Object
  extended by it.unimi.dsi.fastutil.shorts.AbstractShortCollection
      extended by it.unimi.dsi.fastutil.shorts.AbstractShortList
          extended by it.unimi.dsi.fastutil.shorts.ShortLists.Singleton
All Implemented Interfaces:
ShortCollection, ShortIterable, ShortList, ShortStack, Stack<java.lang.Short>, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<java.util.List<? extends java.lang.Short>>, java.lang.Iterable<java.lang.Short>, java.util.Collection<java.lang.Short>, java.util.List<java.lang.Short>
Enclosing class:
ShortLists

public static class ShortLists.Singleton
extends AbstractShortList
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.shorts.AbstractShortList
AbstractShortList.ShortSubList
 
Field Summary
static long serialVersionUID
           
 
Method Summary
 boolean addAll(java.util.Collection<? extends java.lang.Short> c)
          Delegates to a more generic method.
 boolean addAll(int i, java.util.Collection<? extends java.lang.Short> c)
           
 boolean addAll(int i, ShortCollection c)
          Delegates to a more generic method.
 boolean addAll(ShortCollection c)
          Adds all elements of the given type-specific collection to this collection.
 void clear()
           
 java.lang.Object clone()
           
 boolean contains(short k)
           
 short getShort(int i)
           
 ShortListIterator listIterator()
          Returns a type-specific list iterator on the list.
 ShortListIterator listIterator(int i)
          Returns a type-specific list iterator on the list starting at a given index.
 boolean rem(short k)
          Note that this method should be called remove(), but the clash with the similarly named index-based method in the List interface forces us to use a distinguished name.
 boolean removeAll(java.util.Collection<?> c)
          Remove from this collection all elements in the given collection.
 short removeShort(int i)
           
 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.
 ShortList 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.
 short[] toShortArray()
          Returns a primitive type array containing the items of this collection.
 
Methods inherited from class it.unimi.dsi.fastutil.shorts.AbstractShortList
add, add, add, addAll, addAll, addElements, addElements, compareTo, equals, get, getElements, hashCode, indexOf, indexOf, iterator, lastIndexOf, lastIndexOf, peek, peekShort, pop, popShort, push, push, remove, remove, removeElements, set, set, shortListIterator, shortListIterator, shortSubList, top, topShort, toString
 
Methods inherited from class it.unimi.dsi.fastutil.shorts.AbstractShortCollection
add, contains, containsAll, containsAll, isEmpty, rem, removeAll, retainAll, shortIterator, toArray, toArray, toArray, toShortArray
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
add, contains, containsAll, isEmpty, toArray, toArray
 
Methods inherited from interface it.unimi.dsi.fastutil.shorts.ShortCollection
containsAll, removeAll, retainAll, shortIterator, toArray, toArray, toShortArray
 
Methods inherited from interface it.unimi.dsi.fastutil.Stack
isEmpty
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Method Detail

getShort

public short getShort(int i)
Specified by:
getShort in interface ShortList
See Also:
List.get(int)

removeShort

public short removeShort(int i)
Specified by:
removeShort in interface ShortList
Overrides:
removeShort in class AbstractShortList
See Also:
List.remove(int)

contains

public boolean contains(short k)
Specified by:
contains in interface ShortCollection
Overrides:
contains in class AbstractShortList
See Also:
Collection.contains(Object)

addAll

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

Specified by:
addAll in interface java.util.Collection<java.lang.Short>
Specified by:
addAll in interface java.util.List<java.lang.Short>
Overrides:
addAll in class AbstractShortList
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 java.lang.Short> c)
Specified by:
addAll in interface java.util.List<java.lang.Short>
Overrides:
addAll in class AbstractShortList

removeAll

public boolean removeAll(java.util.Collection<?> c)
Description copied from class: AbstractShortCollection
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<java.lang.Short>
Specified by:
removeAll in interface java.util.List<java.lang.Short>
Overrides:
removeAll in class AbstractShortCollection
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: AbstractShortCollection
Retains in this collection only elements from the given collection.

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

toShortArray

public short[] toShortArray()
Description copied from interface: ShortCollection
Returns a primitive type array containing the items of this collection.

Specified by:
toShortArray in interface ShortCollection
Overrides:
toShortArray in class AbstractShortCollection
Returns:
a primitive type array containing the items of this collection.
See Also:
Collection.toArray()

listIterator

public ShortListIterator listIterator()
Description copied from interface: ShortList
Returns a type-specific list iterator on the list.

Specified by:
listIterator in interface ShortList
Specified by:
listIterator in interface java.util.List<java.lang.Short>
Overrides:
listIterator in class AbstractShortList
See Also:
ShortList.listIterator()

listIterator

public ShortListIterator listIterator(int i)
Description copied from interface: ShortList
Returns a type-specific list iterator on the list starting at a given index.

Specified by:
listIterator in interface ShortList
Specified by:
listIterator in interface java.util.List<java.lang.Short>
Overrides:
listIterator in class AbstractShortList
See Also:
ShortList.listIterator(int)

subList

public ShortList subList(int from,
                         int to)
Description copied from interface: ShortList
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 ShortList
Specified by:
subList in interface java.util.List<java.lang.Short>
Overrides:
subList in class AbstractShortList
See Also:
List.subList(int,int)

size

public int size()
Specified by:
size in interface java.util.Collection<java.lang.Short>
Specified by:
size in interface java.util.List<java.lang.Short>

size

public void size(int size)
Description copied from interface: ShortList
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 ShortList
Overrides:
size in class AbstractShortList
Parameters:
size - the new size.

clear

public void clear()
Specified by:
clear in interface java.util.Collection<java.lang.Short>
Specified by:
clear in interface java.util.List<java.lang.Short>
Overrides:
clear in class AbstractShortCollection

clone

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

rem

public boolean rem(short k)
Description copied from interface: ShortCollection
Note that this method should be called remove(), but the clash with the similarly named index-based method in the List interface forces us to use a distinguished name. For simplicity, the set interfaces reinstates remove().

Specified by:
rem in interface ShortCollection
Overrides:
rem in class AbstractShortList
See Also:
Collection.remove(Object)

addAll

public boolean addAll(ShortCollection c)
Description copied from class: AbstractShortCollection
Adds all elements of the given type-specific collection to this collection.

Specified by:
addAll in interface ShortCollection
Overrides:
addAll in class AbstractShortList
Parameters:
c - a type-specific collection.
Returns:
true if this collection changed as a result of the call.
See Also:
Collection.addAll(Collection)

addAll

public boolean addAll(int i,
                      ShortCollection c)
Description copied from class: AbstractShortList
Delegates to a more generic method.

Specified by:
addAll in interface ShortList
Overrides:
addAll in class AbstractShortList
See Also:
List.add(int,Object)