public static class CharLists.Singleton extends AbstractCharList implements java.util.RandomAccess, java.io.Serializable, java.lang.Cloneable
This class may be useful to implement your own in case you subclass a type-specific list.
AbstractCharList.CharRandomAccessSubList, AbstractCharList.CharSubList| Modifier | Constructor and Description |
|---|---|
protected |
Singleton(char element) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addAll(CharCollection c)
Adds all elements of the given type-specific collection to this collection.
|
boolean |
addAll(CharList c)
Appends all of the elements in the specified type-specific list to the end of this type-specific list (optional operation).
|
boolean |
addAll(java.util.Collection<? extends java.lang.Character> c) |
boolean |
addAll(int i,
CharCollection c)
Inserts all of the elements in the specified type-specific collection into this type-specific list at the specified position (optional operation).
|
boolean |
addAll(int i,
CharList c)
Inserts all of the elements in the specified type-specific list into this type-specific list at the specified position (optional operation).
|
boolean |
addAll(int i,
java.util.Collection<? extends java.lang.Character> c)
Adds all of the elements in the specified collection to this list (optional operation).
|
void |
addElements(int index,
char[] a)
Add (hopefully quickly) elements to this type-specific list.
|
void |
addElements(int index,
char[] a,
int offset,
int length)
Add (hopefully quickly) elements to this type-specific list.
|
void |
clear() |
java.lang.Object |
clone() |
boolean |
contains(char k)
Returns true if this list contains the specified element.
|
void |
forEach(it.unimi.dsi.fastutil.chars.CharConsumer action)
Performs the given action for each element of this type-specific
Iterable
until all elements have been processed or the action throws an
exception. |
void |
forEach(java.util.function.Consumer<? super java.lang.Character> action)
Deprecated.
|
char |
getChar(int i)
Returns the element at the specified position in this list.
|
void |
getElements(int from,
char[] a,
int offset,
int length)
Copies (hopefully quickly) elements of this type-specific list into the given array.
|
int |
indexOf(char k)
Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
|
it.unimi.dsi.fastutil.ints.IntIterator |
intIterator()
Returns a widened primitive iterator on the elements of this collection.
|
it.unimi.dsi.fastutil.ints.IntSpliterator |
intSpliterator()
Returns widened primitive spliterator on the elements of this collection.
|
CharListIterator |
iterator()
Returns a type-specific iterator on the elements of this collection.
|
CharListIterator |
listIterator()
Returns a type-specific list iterator on the list.
|
CharListIterator |
listIterator(int i)
Returns a type-specific list iterator on the list starting at a given index.
|
boolean |
rem(char k)
Removes a single instance of the specified element from this collection, if it is present (optional operation).
|
boolean |
removeAll(CharCollection c)
Remove from this collection all elements in the given type-specific collection.
|
boolean |
removeAll(java.util.Collection<?> c) |
char |
removeChar(int i)
Removes the element at the specified position in this list (optional operation).
|
void |
removeElements(int from,
int to)
Removes (hopefully quickly) elements of this type-specific list.
|
boolean |
removeIf(CharPredicate filter)
Remove from this collection all elements which satisfy the given predicate.
|
boolean |
removeIf(java.util.function.Predicate<? super java.lang.Character> filter)
Deprecated.
|
void |
replaceAll(CharUnaryOperator operator)
Replaces each element of this list with the result of applying the
operator to that element.
|
void |
replaceAll(java.util.function.UnaryOperator<java.lang.Character> operator)
Deprecated.
|
boolean |
retainAll(CharCollection c)
Retains in this collection only elements from the given type-specific collection.
|
boolean |
retainAll(java.util.Collection<?> c) |
void |
setElements(char[] a)
Set (hopefully quickly) elements to match the array given.
|
void |
setElements(int index,
char[] a)
Set (hopefully quickly) elements to match the array given.
|
void |
setElements(int index,
char[] a,
int offset,
int length)
Set (hopefully quickly) elements to match the array given.
|
int |
size() |
void |
size(int size)
Sets the size of this list.
|
void |
sort(it.unimi.dsi.fastutil.chars.CharComparator comparator)
Sort a list using a type-specific comparator.
|
void |
sort(java.util.Comparator<? super java.lang.Character> comparator)
Deprecated.
|
it.unimi.dsi.fastutil.chars.CharSpliterator |
spliterator()
Returns a type-specific spliterator on the elements of this list.
|
CharList |
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()
Deprecated.
|
char[] |
toCharArray()
Returns a primitive type array containing the items of this collection.
|
void |
unstableSort(it.unimi.dsi.fastutil.chars.CharComparator comparator)
Sorts this list using a sort not assured to be stable.
|
void |
unstableSort(java.util.Comparator<? super java.lang.Character> comparator)
Deprecated.
|
add, add, compareTo, ensureIndex, ensureRestrictedIndex, equals, hashCode, lastIndexOf, peekChar, popChar, push, set, toArray, topChar, toStringadd, contains, containsAll, containsAll, remove, toCharArrayfinalize, getClass, notify, notifyAll, wait, wait, waitadd, add, contains, get, indexOf, lastIndexOf, of, of, of, of, of, remove, remove, replaceAll, setcontainsAll, intParallelStream, intStream, parallelStream, removeIf, stream, toCharArrayforEachpublic char getChar(int i)
CharListpublic boolean rem(char k)
AbstractCharListrem in interface CharCollectionrem in class AbstractCharListList.remove(Object)public char removeChar(int i)
AbstractCharListremoveChar in interface CharListremoveChar in class AbstractCharListList.remove(int)public boolean contains(char k)
AbstractCharListcontains in interface CharCollectioncontains in class AbstractCharListList.contains(Object)public int indexOf(char k)
CharListindexOf in interface CharListindexOf in class AbstractCharListList.indexOf(Object)public char[] toCharArray()
CharCollectiontoCharArray in interface CharCollectiontoCharArray in class AbstractCharListCollection.toArray()public CharListIterator listIterator()
AbstractCharListlistIterator in interface CharListlistIterator in interface java.util.List<java.lang.Character>listIterator in class AbstractCharListList.listIterator()public CharListIterator iterator()
AbstractCharListiterator in interface CharCollectioniterator in interface CharIterableiterator in interface CharListiterator in interface java.lang.Iterable<java.lang.Character>iterator in interface java.util.Collection<java.lang.Character>iterator in interface java.util.List<java.lang.Character>iterator in class AbstractCharListIterable.iterator()public it.unimi.dsi.fastutil.chars.CharSpliterator spliterator()
CharListList spliterators must report at least Spliterator.SIZED and Spliterator.ORDERED.
See List.spliterator() for more documentation on the requirements
of the returned spliterator.
spliterator in interface CharCollectionspliterator in interface CharIterablespliterator in interface CharListspliterator in interface java.lang.Iterable<java.lang.Character>spliterator in interface java.util.Collection<java.lang.Character>spliterator in interface java.util.List<java.lang.Character>public CharListIterator listIterator(int i)
AbstractCharListlistIterator in interface CharListlistIterator in interface java.util.List<java.lang.Character>listIterator in class AbstractCharListList.listIterator(int)public CharList subList(int from, int to)
CharListfrom, inclusive, to the index to, exclusive.subList in interface CharListsubList in interface java.util.List<java.lang.Character>subList in class AbstractCharListList.subList(int,int)@Deprecated public void forEach(java.util.function.Consumer<? super java.lang.Character> action)
CharIterableforEach in interface CharIterableforEach in interface java.lang.Iterable<java.lang.Character>public boolean addAll(int i,
java.util.Collection<? extends java.lang.Character> c)
AbstractCharListaddAll in interface java.util.List<java.lang.Character>addAll in class AbstractCharListpublic boolean addAll(java.util.Collection<? extends java.lang.Character> c)
AbstractCharListaddAll in interface java.util.Collection<java.lang.Character>addAll in interface java.util.List<java.lang.Character>addAll in class AbstractCharListpublic boolean removeAll(java.util.Collection<?> c)
AbstractCharCollectionremoveAll in interface java.util.Collection<java.lang.Character>removeAll in interface java.util.List<java.lang.Character>removeAll in class AbstractCharCollectionpublic boolean retainAll(java.util.Collection<?> c)
AbstractCharCollectionretainAll in interface java.util.Collection<java.lang.Character>retainAll in interface java.util.List<java.lang.Character>retainAll in class AbstractCharCollection@Deprecated public boolean removeIf(java.util.function.Predicate<? super java.lang.Character> filter)
CharCollectionremoveIf in interface CharCollectionremoveIf in interface java.util.Collection<java.lang.Character>@Deprecated public void replaceAll(java.util.function.UnaryOperator<java.lang.Character> operator)
CharListreplaceAll in interface CharListreplaceAll in interface java.util.List<java.lang.Character>public void replaceAll(CharUnaryOperator operator)
CharListreplaceAll in interface CharListoperator - the operator to apply to each element.List.replaceAll(java.util.function.UnaryOperator<E>)public void forEach(it.unimi.dsi.fastutil.chars.CharConsumer action)
AbstractCharListIterable
until all elements have been processed or the action throws an
exception.forEach in interface CharIterableforEach in class AbstractCharListaction - the action to be performed for each element.Iterable.forEach(java.util.function.Consumer)public boolean addAll(CharList c)
CharListpublic boolean addAll(int i,
CharList c)
CharListpublic boolean addAll(int i,
CharCollection c)
CharListaddAll in interface CharListaddAll in class AbstractCharListList.addAll(int,java.util.Collection)public boolean addAll(CharCollection c)
AbstractCharListaddAll in interface CharCollectionaddAll in class AbstractCharListc - a type-specific collection.true if this collection changed as a result of the call.Collection.addAll(Collection)public boolean removeAll(CharCollection c)
CharCollectionremoveAll in interface CharCollectionremoveAll in class AbstractCharCollectionc - a type-specific collection.true if this collection changed as a result of the call.Collection.removeAll(Collection)public boolean retainAll(CharCollection c)
CharCollectionretainAll in interface CharCollectionretainAll in class AbstractCharCollectionc - a type-specific collection.true if this collection changed as a result of the call.Collection.retainAll(Collection)public boolean removeIf(CharPredicate filter)
CharCollectionremoveIf in interface CharCollectionfilter - a predicate which returns true for elements to be
removed.true if any elements were removed.Collection.removeIf(java.util.function.Predicate)public it.unimi.dsi.fastutil.ints.IntIterator intIterator()
CharCollection
This method is provided for the purpose of APIs that expect only the JDK's
primitive iterators, of which there are only int, long, and double.
WARNING: This is not the same as converting the source to a sequence
of code points. This returned instance literally performs (int)(charValue) casts.
Surrogate pairs will be left as separate elements instead of combined into a single element
with the code point it represents. See Character for more discussion on code points,
char values, and surrogate pairs.
intIterator in interface CharCollectionintIterator in interface CharIterablepublic it.unimi.dsi.fastutil.ints.IntSpliterator intSpliterator()
CharCollection
This method is provided for the purpose of APIs that expect only the JDK's
primitive spliterators, of which there are only int, long, and double.
WARNING: This is not the same as converting the source to a sequence
of code points. This returned instance literally performs (int)(charValue) casts.
Surrogate pairs will be left as separate elements instead of combined into a single element
with the code point it represents. See Character for more discussion on code points,
char values, and surrogate pairs.
intSpliterator in interface CharCollectionintSpliterator in interface CharIterable@Deprecated public java.lang.Object[] toArray()
toArray in interface java.util.Collection<java.lang.Character>toArray in interface java.util.List<java.lang.Character>toArray in class java.util.AbstractCollection<java.lang.Character>public void sort(it.unimi.dsi.fastutil.chars.CharComparator comparator)
CharListPass null to sort using natural ordering.
public void unstableSort(it.unimi.dsi.fastutil.chars.CharComparator comparator)
CharListPass null to sort using natural ordering.
This differs from List.sort(java.util.Comparator) in that the results are
not assured to be stable, but may be a bit faster.
Unless a subclass specifies otherwise, the results of the method if the list is concurrently modified during the sort are unspecified.
unstableSort in interface CharList@Deprecated public void sort(java.util.Comparator<? super java.lang.Character> comparator)
CharList@Deprecated public void unstableSort(java.util.Comparator<? super java.lang.Character> comparator)
CharListunstableSort in interface CharListpublic void getElements(int from,
char[] a,
int offset,
int length)
AbstractCharListThis is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.
getElements in interface CharListgetElements in class AbstractCharListfrom - the start index (inclusive).a - the destination array.offset - the offset into the destination array where to store the first element copied.length - the number of elements to be copied.public void removeElements(int from,
int to)
AbstractCharListThis is a trivial iterator-based based implementation. It is expected that implementations will override this method with a more optimized version.
removeElements in interface CharListremoveElements in class AbstractCharListfrom - the start index (inclusive).to - the end index (exclusive).public void addElements(int index,
char[] a)
AbstractCharListaddElements in interface CharListaddElements in class AbstractCharListindex - the index at which to add elements.a - the array containing the elements.public void addElements(int index,
char[] a,
int offset,
int length)
AbstractCharListThis is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.
addElements in interface CharListaddElements in class AbstractCharListindex - the index at which to add elements.a - the array containing the elements.offset - the offset of the first element to add.length - the number of elements to add.public void setElements(char[] a)
CharListsetElements in interface CharLista - the array containing the elements.public void setElements(int index,
char[] a)
CharListsetElements in interface CharListindex - the index at which to start setting elements.a - the array containing the elements.public void setElements(int index,
char[] a,
int offset,
int length)
CharList
ListIterator iter = listIterator(index);
int i = 0;
while (i < length) {
iter.next();
iter.set(a[offset + i++]);
}
However, the exact implementation may be more efficient, taking into account
whether random access is faster or not, or at the discretion of subclasses,
abuse internals.setElements in interface CharListsetElements in class AbstractCharListindex - the index at which to start setting elements.a - the array containing the elementsoffset - the offset of the first element to add.length - the number of elements to add.public int size()
size in interface java.util.Collection<java.lang.Character>size in interface java.util.List<java.lang.Character>size in class java.util.AbstractCollection<java.lang.Character>public void size(int size)
CharListIf the specified size is smaller than the current size, the last elements are
discarded. Otherwise, they are filled with 0/null/false.
size in interface CharListsize in class AbstractCharListsize - the new size.public void clear()
AbstractCharListclear in interface java.util.Collection<java.lang.Character>clear in interface java.util.List<java.lang.Character>clear in class AbstractCharListpublic java.lang.Object clone()
clone in class java.lang.Object