it.unimi.dsi.fastutil.longs
Class LongLists.Singleton

java.lang.Object
  extended by java.util.AbstractCollection<java.lang.Long>
      extended by it.unimi.dsi.fastutil.longs.AbstractLongCollection
          extended by it.unimi.dsi.fastutil.longs.AbstractLongList
              extended by it.unimi.dsi.fastutil.longs.LongLists.Singleton
All Implemented Interfaces:
LongCollection, LongIterable, LongList, LongStack, Stack<java.lang.Long>, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<java.util.List<? extends java.lang.Long>>, java.lang.Iterable<java.lang.Long>, java.util.Collection<java.lang.Long>, java.util.List<java.lang.Long>
Enclosing class:
LongLists

public static class LongLists.Singleton
extends AbstractLongList
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.longs.AbstractLongList
AbstractLongList.LongSubList
 
Method Summary
 boolean addAll(java.util.Collection<? extends java.lang.Long> c)
          Delegates to a more generic method.
 boolean addAll(int i, java.util.Collection<? extends java.lang.Long> c)
           
 boolean addAll(int i, LongCollection c)
          Delegates to a more generic method.
 boolean addAll(LongCollection c)
          Adds all elements of the given type-specific collection to this collection.
 void clear()
           
 java.lang.Object clone()
           
 boolean contains(long k)
           
 long getLong(int i)
           
 LongListIterator iterator()
          Returns a type-specific iterator on the elements of this collection.
 LongListIterator listIterator()
          Returns a type-specific list iterator on the list.
 LongListIterator listIterator(int i)
          Returns a type-specific list iterator on the list starting at a given index.
 boolean rem(long 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.
 long removeLong(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.
 LongList 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.
 long[] toLongArray()
          Returns a primitive type array containing the items of this collection.
 
Methods inherited from class it.unimi.dsi.fastutil.longs.AbstractLongList
add, add, add, addAll, addAll, addElements, addElements, compareTo, equals, get, getElements, hashCode, indexOf, indexOf, lastIndexOf, lastIndexOf, longListIterator, longListIterator, longSubList, peek, peekLong, pop, popLong, push, push, remove, remove, removeElements, set, set, top, topLong, toString
 
Methods inherited from class it.unimi.dsi.fastutil.longs.AbstractLongCollection
add, contains, containsAll, containsAll, isEmpty, longIterator, rem, removeAll, retainAll, toArray, toArray, toArray, toLongArray
 
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.longs.LongCollection
containsAll, longIterator, removeAll, retainAll, toArray, toArray, toLongArray
 
Methods inherited from interface it.unimi.dsi.fastutil.Stack
isEmpty
 

Method Detail

getLong

public long getLong(int i)
Specified by:
getLong in interface LongList
See Also:
List.get(int)

removeLong

public long removeLong(int i)
Specified by:
removeLong in interface LongList
Overrides:
removeLong in class AbstractLongList
See Also:
List.remove(int)

contains

public boolean contains(long k)
Specified by:
contains in interface LongCollection
Overrides:
contains in class AbstractLongList
See Also:
Collection.contains(Object)

addAll

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

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

removeAll

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

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

toLongArray

public long[] toLongArray()
Description copied from interface: LongCollection
Returns a primitive type array containing the items of this collection.

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

listIterator

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

Specified by:
listIterator in interface LongList
Specified by:
listIterator in interface java.util.List<java.lang.Long>
Overrides:
listIterator in class AbstractLongList
See Also:
List.listIterator()

iterator

public LongListIterator iterator()
Description copied from interface: LongCollection
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 LongCollection
Specified by:
iterator in interface LongIterable
Specified by:
iterator in interface LongList
Specified by:
iterator in interface java.lang.Iterable<java.lang.Long>
Specified by:
iterator in interface java.util.Collection<java.lang.Long>
Specified by:
iterator in interface java.util.List<java.lang.Long>
Overrides:
iterator in class AbstractLongList
Returns:
a type-specific iterator on the elements of this collection.

listIterator

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

Specified by:
listIterator in interface LongList
Specified by:
listIterator in interface java.util.List<java.lang.Long>
Overrides:
listIterator in class AbstractLongList
See Also:
List.listIterator(int)

subList

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

size

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

size

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

clear

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

clone

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

rem

public boolean rem(long k)
Description copied from interface: LongCollection
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 LongCollection
Overrides:
rem in class AbstractLongList
See Also:
Collection.remove(Object)

addAll

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

Specified by:
addAll in interface LongCollection
Overrides:
addAll in class AbstractLongList
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,
                      LongCollection c)
Description copied from class: AbstractLongList
Delegates to a more generic method.

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