Class ReferenceLists.Singleton<K>
- java.lang.Object
-
- java.util.AbstractCollection<K>
-
- it.unimi.dsi.fastutil.objects.AbstractReferenceCollection<K>
-
- it.unimi.dsi.fastutil.objects.AbstractReferenceList<K>
-
- it.unimi.dsi.fastutil.objects.ReferenceLists.Singleton<K>
-
- All Implemented Interfaces:
ObjectIterable<K>,ReferenceCollection<K>,ReferenceList<K>,Stack<K>,Serializable,Cloneable,Iterable<K>,Collection<K>,List<K>,RandomAccess
- Enclosing class:
- ReferenceLists
public static class ReferenceLists.Singleton<K> extends AbstractReferenceList<K> implements RandomAccess, Serializable, 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.AbstractReferenceList
AbstractReferenceList.ReferenceSubList<K>
-
-
Method Summary
Modifier and Type Method Description booleanaddAll(int i, Collection<? extends K> c)Adds all of the elements in the specified collection to this list (optional operation).booleanaddAll(Collection<? extends K> c)voidclear()Objectclone()booleancontains(Object k)Returns true if this list contains the specified element.Kget(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.Kremove(int i)booleanremove(Object k)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)intsize()voidsize(int size)Sets the size of this list.ReferenceList<K>subList(int from, int to)Returns a type-specific view of the portion of this list from the indexfrom, inclusive, to the indexto, exclusive.Object[]toArray()-
Methods inherited from class it.unimi.dsi.fastutil.objects.AbstractReferenceList
add, add, addElements, addElements, equals, getElements, hashCode, indexOf, lastIndexOf, peek, pop, push, removeElements, set, top, toString
-
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, toArray
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
containsAll, isEmpty, replaceAll, sort, spliterator, toArray
-
-
-
-
Method Detail
-
remove
public boolean remove(Object k)
- Specified by:
removein interfaceCollection<K>- Specified by:
removein interfaceList<K>- Overrides:
removein classAbstractCollection<K>
-
remove
public K remove(int i)
Description copied from class:AbstractReferenceListThis implementation always throws an
UnsupportedOperationException.
-
contains
public boolean contains(Object k)
Description copied from class:AbstractReferenceListReturns true if this list contains the specified element.This implementation delegates to
indexOf().- Specified by:
containsin interfaceCollection<K>- Specified by:
containsin interfaceList<K>- Overrides:
containsin classAbstractReferenceList<K>- See Also:
List.contains(Object)
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection<K>- Specified by:
toArrayin interfaceList<K>- Overrides:
toArrayin classAbstractCollection<K>
-
listIterator
public ObjectListIterator<K> listIterator()
Description copied from class:AbstractReferenceListReturns a type-specific list iterator on the list.This implementation delegates to
listIterator(0).- Specified by:
listIteratorin interfaceList<K>- Specified by:
listIteratorin interfaceReferenceList<K>- Overrides:
listIteratorin classAbstractReferenceList<K>- See Also:
List.listIterator()
-
iterator
public ObjectListIterator<K> iterator()
Description copied from class:AbstractReferenceListReturns 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 extendsCollection.This implementation delegates to
AbstractReferenceList.listIterator().- Specified by:
iteratorin interfaceCollection<K>- Specified by:
iteratorin interfaceIterable<K>- Specified by:
iteratorin interfaceList<K>- Specified by:
iteratorin interfaceObjectIterable<K>- Specified by:
iteratorin interfaceReferenceCollection<K>- Specified by:
iteratorin interfaceReferenceList<K>- Overrides:
iteratorin classAbstractReferenceList<K>- Returns:
- a type-specific iterator on the elements of this collection.
- See Also:
Iterable.iterator()
-
listIterator
public ObjectListIterator<K> listIterator(int i)
Description copied from class:AbstractReferenceListReturns a type-specific list iterator on the list starting at a given index.This implementation is based on the random-access methods.
- Specified by:
listIteratorin interfaceList<K>- Specified by:
listIteratorin interfaceReferenceList<K>- Overrides:
listIteratorin classAbstractReferenceList<K>- See Also:
List.listIterator(int)
-
subList
public ReferenceList<K> subList(int from, int to)
Description copied from interface:ReferenceListReturns a type-specific view of the portion of this list from the indexfrom, inclusive, to the indexto, exclusive.Note that this specification strengthens the one given in
List.subList(int,int).- Specified by:
subListin interfaceList<K>- Specified by:
subListin interfaceReferenceList<K>- Overrides:
subListin classAbstractReferenceList<K>- See Also:
List.subList(int,int)
-
addAll
public boolean addAll(int i, Collection<? extends K> c)Description copied from class:AbstractReferenceListAdds all of the elements in the specified collection to this list (optional operation).
-
addAll
public boolean addAll(Collection<? extends K> c)
Description copied from class:AbstractReferenceListThis implementation delegates to the type-specific version of
List.addAll(int, Collection).- Specified by:
addAllin interfaceCollection<K>- Specified by:
addAllin interfaceList<K>- Overrides:
addAllin classAbstractReferenceList<K>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<K>- Specified by:
removeAllin interfaceList<K>- Overrides:
removeAllin classAbstractCollection<K>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<K>- Specified by:
retainAllin interfaceList<K>- Overrides:
retainAllin classAbstractCollection<K>
-
size
public int size()
- Specified by:
sizein interfaceCollection<K>- Specified by:
sizein interfaceList<K>- Specified by:
sizein classAbstractCollection<K>
-
size
public void size(int size)
Description copied from interface:ReferenceListSets 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:
sizein interfaceReferenceList<K>- Overrides:
sizein classAbstractReferenceList<K>- Parameters:
size- the new size.
-
clear
public void clear()
Description copied from class:AbstractReferenceListThis implementation delegates to
AbstractReferenceList.removeElements(int, int).- Specified by:
clearin interfaceCollection<K>- Specified by:
clearin interfaceList<K>- Overrides:
clearin classAbstractReferenceList<K>
-
clone
public Object clone()
-
-