Class IntLists.Singleton
- java.lang.Object
-
- java.util.AbstractCollection<Integer>
-
- it.unimi.dsi.fastutil.ints.AbstractIntCollection
-
- it.unimi.dsi.fastutil.ints.AbstractIntList
-
- it.unimi.dsi.fastutil.ints.IntLists.Singleton
-
- All Implemented Interfaces:
IntCollection,IntIterable,IntList,IntStack,Stack<Integer>,Serializable,Cloneable,Comparable<List<? extends Integer>>,Iterable<Integer>,Collection<Integer>,List<Integer>,RandomAccess
- Enclosing class:
- IntLists
public static class IntLists.Singleton extends AbstractIntList 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.ints.AbstractIntList
AbstractIntList.IntSubList
-
-
Method Summary
Modifier and Type Method Description booleanaddAll(int i, IntCollection c)Inserts all of the elements in the specified type-specific collection into this type-specific list at the specified position (optional operation).booleanaddAll(int i, IntList c)Inserts all of the elements in the specified type-specific list into this type-specific list at the specified position (optional operation).booleanaddAll(int i, Collection<? extends Integer> c)Adds all of the elements in the specified collection to this list (optional operation).booleanaddAll(IntCollection c)Adds all elements of the given type-specific collection to this collection.booleanaddAll(IntList c)Appends all of the elements in the specified type-specific list to the end of this type-specific list (optional operation).booleanaddAll(Collection<? extends Integer> c)voidclear()Objectclone()booleancontains(int k)Returns true if this list contains the specified element.intgetInt(int i)Returns the element at the specified position in this list.IntListIteratoriterator()Returns a type-specific iterator on the elements of this collection.IntListIteratorlistIterator()Returns a type-specific list iterator on the list.IntListIteratorlistIterator(int i)Returns a type-specific list iterator on the list starting at a given index.booleanrem(int k)Removes a single instance of the specified element from this collection, if it is present (optional operation).booleanremoveAll(IntCollection c)Remove from this collection all elements in the given type-specific collection.booleanremoveAll(Collection<?> c)intremoveInt(int i)Removes the element at the specified position in this list (optional operation).booleanretainAll(IntCollection c)Retains in this collection only elements from the given type-specific collection.booleanretainAll(Collection<?> c)intsize()voidsize(int size)Sets the size of this list.IntListsubList(int from, int to)Returns a type-specific view of the portion of this list from the indexfrom, inclusive, to the indexto, exclusive.int[]toIntArray()Returns a primitive type array containing the items of this collection.-
Methods inherited from class it.unimi.dsi.fastutil.ints.AbstractIntList
add, add, addElements, addElements, compareTo, equals, getElements, hashCode, indexOf, lastIndexOf, peekInt, popInt, push, removeElements, set, topInt, toString
-
Methods inherited from class it.unimi.dsi.fastutil.ints.AbstractIntCollection
add, contains, containsAll, remove, toArray, toIntArray
-
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, toArray, toArray
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Methods inherited from interface it.unimi.dsi.fastutil.ints.IntCollection
containsAll, removeIf, removeIf, toArray, toIntArray
-
Methods inherited from interface it.unimi.dsi.fastutil.ints.IntIterable
forEach, forEach
-
Methods inherited from interface it.unimi.dsi.fastutil.ints.IntList
add, add, contains, get, indexOf, lastIndexOf, remove, remove, set
-
Methods inherited from interface java.util.List
containsAll, isEmpty, replaceAll, sort, spliterator, toArray, toArray
-
-
-
-
Method Detail
-
getInt
public int getInt(int i)
Description copied from interface:IntListReturns the element at the specified position in this list.- Specified by:
getIntin interfaceIntList- See Also:
List.get(int)
-
rem
public boolean rem(int k)
Description copied from class:AbstractIntListRemoves a single instance of the specified element from this collection, if it is present (optional operation).This implementation delegates to
indexOf().- Specified by:
remin interfaceIntCollection- Overrides:
remin classAbstractIntList- See Also:
List.remove(Object)
-
removeInt
public int removeInt(int i)
Description copied from class:AbstractIntListRemoves the element at the specified position in this list (optional operation).This implementation always throws an
UnsupportedOperationException.- Specified by:
removeIntin interfaceIntList- Overrides:
removeIntin classAbstractIntList- See Also:
List.remove(int)
-
contains
public boolean contains(int k)
Description copied from class:AbstractIntListReturns true if this list contains the specified element.This implementation delegates to
indexOf().- Specified by:
containsin interfaceIntCollection- Overrides:
containsin classAbstractIntList- See Also:
List.contains(Object)
-
toIntArray
public int[] toIntArray()
Description copied from interface:IntCollectionReturns a primitive type array containing the items of this collection.- Specified by:
toIntArrayin interfaceIntCollection- Overrides:
toIntArrayin classAbstractIntCollection- Returns:
- a primitive type array containing the items of this collection.
- See Also:
Collection.toArray()
-
listIterator
public IntListIterator listIterator()
Description copied from class:AbstractIntListReturns a type-specific list iterator on the list.This implementation delegates to
listIterator(0).- Specified by:
listIteratorin interfaceIntList- Specified by:
listIteratorin interfaceList<Integer>- Overrides:
listIteratorin classAbstractIntList- See Also:
List.listIterator()
-
iterator
public IntListIterator iterator()
Description copied from class:AbstractIntListReturns 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
AbstractIntList.listIterator().- Specified by:
iteratorin interfaceCollection<Integer>- Specified by:
iteratorin interfaceIntCollection- Specified by:
iteratorin interfaceIntIterable- Specified by:
iteratorin interfaceIntList- Specified by:
iteratorin interfaceIterable<Integer>- Specified by:
iteratorin interfaceList<Integer>- Overrides:
iteratorin classAbstractIntList- Returns:
- a type-specific iterator on the elements of this collection.
- See Also:
Iterable.iterator()
-
listIterator
public IntListIterator listIterator(int i)
Description copied from class:AbstractIntListReturns 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 interfaceIntList- Specified by:
listIteratorin interfaceList<Integer>- Overrides:
listIteratorin classAbstractIntList- See Also:
List.listIterator(int)
-
subList
public IntList subList(int from, int to)
Description copied from interface:IntListReturns 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 interfaceIntList- Specified by:
subListin interfaceList<Integer>- Overrides:
subListin classAbstractIntList- See Also:
List.subList(int,int)
-
addAll
public boolean addAll(int i, Collection<? extends Integer> c)Description copied from class:AbstractIntListAdds all of the elements in the specified collection to this list (optional operation).- Specified by:
addAllin interfaceList<Integer>- Overrides:
addAllin classAbstractIntList
-
addAll
public boolean addAll(Collection<? extends Integer> c)
Description copied from class:AbstractIntListThis implementation delegates to the type-specific version of
List.addAll(int, Collection).- Specified by:
addAllin interfaceCollection<Integer>- Specified by:
addAllin interfaceList<Integer>- Overrides:
addAllin classAbstractIntList
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<Integer>- Specified by:
removeAllin interfaceList<Integer>- Overrides:
removeAllin classAbstractCollection<Integer>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<Integer>- Specified by:
retainAllin interfaceList<Integer>- Overrides:
retainAllin classAbstractCollection<Integer>
-
addAll
public boolean addAll(IntList c)
Description copied from class:AbstractIntListAppends all of the elements in the specified type-specific list to the end of this type-specific list (optional operation).This implementation delegates to the type-specific list version of
List.addAll(int, Collection).- Specified by:
addAllin interfaceIntList- Overrides:
addAllin classAbstractIntList- See Also:
List.add(int,Object)
-
addAll
public boolean addAll(int i, IntList c)Description copied from class:AbstractIntListInserts all of the elements in the specified type-specific list into this type-specific list at the specified position (optional operation).This implementation delegates to the type-specific version of
List.addAll(int, Collection).- Specified by:
addAllin interfaceIntList- Overrides:
addAllin classAbstractIntList- See Also:
List.add(int,Object)
-
addAll
public boolean addAll(int i, IntCollection c)Description copied from interface:IntListInserts all of the elements in the specified type-specific collection into this type-specific list at the specified position (optional operation).- Specified by:
addAllin interfaceIntList- Overrides:
addAllin classAbstractIntList- See Also:
List.addAll(int,java.util.Collection)
-
addAll
public boolean addAll(IntCollection c)
Description copied from class:AbstractIntListAdds all elements of the given type-specific collection to this collection.This implementation delegates to the type-specific version of
List.addAll(int, Collection).- Specified by:
addAllin interfaceIntCollection- Overrides:
addAllin classAbstractIntList- Parameters:
c- a type-specific collection.- Returns:
trueif this collection changed as a result of the call.- See Also:
Collection.addAll(Collection)
-
removeAll
public boolean removeAll(IntCollection c)
Description copied from interface:IntCollectionRemove from this collection all elements in the given type-specific collection.- Specified by:
removeAllin interfaceIntCollection- Overrides:
removeAllin classAbstractIntCollection- Parameters:
c- a type-specific collection.- Returns:
trueif this collection changed as a result of the call.- See Also:
Collection.removeAll(Collection)
-
retainAll
public boolean retainAll(IntCollection c)
Description copied from interface:IntCollectionRetains in this collection only elements from the given type-specific collection.- Specified by:
retainAllin interfaceIntCollection- Overrides:
retainAllin classAbstractIntCollection- Parameters:
c- a type-specific collection.- Returns:
trueif this collection changed as a result of the call.- See Also:
Collection.retainAll(Collection)
-
size
public int size()
- Specified by:
sizein interfaceCollection<Integer>- Specified by:
sizein interfaceList<Integer>- Specified by:
sizein classAbstractCollection<Integer>
-
size
public void size(int size)
Description copied from interface:IntListSets 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 interfaceIntList- Overrides:
sizein classAbstractIntList- Parameters:
size- the new size.
-
clear
public void clear()
Description copied from class:AbstractIntListThis implementation delegates to
AbstractIntList.removeElements(int, int).- Specified by:
clearin interfaceCollection<Integer>- Specified by:
clearin interfaceList<Integer>- Overrides:
clearin classAbstractIntList
-
clone
public Object clone()
-
-