public class CharImmutableList extends AbstractCharList implements CharList, java.util.RandomAccess, java.lang.Cloneable, java.io.Serializable
Instances of this class are immutable and (contrarily to mutable array-based list implementations) the backing array is not exposed. Instances can be built using a variety of methods, but note that constructors using an array will not make a defensive copy.
This class implements the bulk method getElements() using
high-performance system calls (e.g., System.arraycopy()) instead of
expensive loops.
AbstractCharList.CharRandomAccessSubList, AbstractCharList.CharSubList| Constructor and Description |
|---|
CharImmutableList(char[] a)
Creates a new immutable list using a given array.
|
CharImmutableList(char[] a,
int offset,
int length)
Creates a new immutable list and fills it with the elements of a given array.
|
CharImmutableList(CharCollection c)
Creates a new immutable list and fills it with a given type-specific collection.
|
CharImmutableList(it.unimi.dsi.fastutil.chars.CharIterator i)
Creates a new immutable list and fills it with the elements returned by a type-specific iterator..
|
CharImmutableList(CharList l)
Creates a new immutable list and fills it with a given type-specific list.
|
CharImmutableList(java.util.Collection<? extends java.lang.Character> c)
Creates a new immutable list and fills it with a given collection.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(char k)
Deprecated.
|
boolean |
add(java.lang.Character k)
Deprecated.
|
void |
add(int index,
char k)
Deprecated.
|
void |
add(int index,
java.lang.Character k)
Deprecated.
|
boolean |
addAll(CharCollection c)
Deprecated.
|
boolean |
addAll(CharList c)
Deprecated.
|
boolean |
addAll(java.util.Collection<? extends java.lang.Character> c)
Deprecated.
|
boolean |
addAll(int index,
CharCollection c)
Deprecated.
|
boolean |
addAll(int index,
CharList c)
Deprecated.
|
boolean |
addAll(int index,
java.util.Collection<? extends java.lang.Character> c)
Deprecated.
|
void |
addElements(int index,
char[] a,
int offset,
int length)
Deprecated.
|
void |
clear()
Deprecated.
|
CharImmutableList |
clone() |
int |
compareTo(CharImmutableList l)
Compares this immutable list to another immutable list.
|
int |
compareTo(java.util.List<? extends java.lang.Character> l)
Compares this list to another object.
|
boolean |
equals(CharImmutableList l)
Compares this type-specific immutable list to another one.
|
boolean |
equals(java.lang.Object o) |
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. |
char |
getChar(int index)
Returns the element at the specified position in this list.
|
void |
getElements(int from,
char[] a,
int offset,
int length)
Copies element of this type-specific list into the given array using optimized system calls.
|
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.
|
boolean |
isEmpty() |
int |
lastIndexOf(char k)
Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
|
CharListIterator |
listIterator(int index)
Returns a type-specific list iterator on the list starting at a given index.
|
static CharImmutableList |
of()
Returns an empty immutable list.
|
static CharImmutableList |
of(char... init)
Creates an immutable list using a list of elements.
|
boolean |
rem(char k)
Deprecated.
|
java.lang.Character |
remove(int index)
Deprecated.
|
boolean |
remove(java.lang.Object k)
Deprecated.
|
boolean |
removeAll(CharCollection c)
Deprecated.
|
boolean |
removeAll(java.util.Collection<?> c)
Deprecated.
|
char |
removeChar(int index)
Deprecated.
|
void |
removeElements(int from,
int to)
Deprecated.
|
boolean |
removeIf(CharPredicate c)
Deprecated.
|
boolean |
removeIf(java.util.function.Predicate<? super java.lang.Character> c)
Deprecated.
|
void |
replaceAll(java.util.function.IntUnaryOperator operator)
Deprecated.
|
void |
replaceAll(java.util.function.UnaryOperator<java.lang.Character> operator)
Deprecated.
|
boolean |
retainAll(CharCollection c)
Deprecated.
|
boolean |
retainAll(java.util.Collection<?> c)
Deprecated.
|
char |
set(int index,
char k)
Deprecated.
|
java.lang.Character |
set(int index,
java.lang.Character k)
Deprecated.
|
void |
setElements(int index,
char[] a,
int offset,
int length)
Deprecated.
|
int |
size() |
void |
size(int size)
Deprecated.
|
void |
sort(it.unimi.dsi.fastutil.chars.CharComparator comp)
Deprecated.
|
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. |
char[] |
toArray(char[] a)
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
|
char[] |
toCharArray()
Returns a primitive type array containing the items of this collection.
|
void |
unstableSort(it.unimi.dsi.fastutil.chars.CharComparator comp)
Deprecated.
|
void |
unstableSort(java.util.Comparator<? super java.lang.Character> comparator)
Deprecated.
|
addElements, contains, ensureIndex, ensureRestrictedIndex, hashCode, iterator, listIterator, peekChar, popChar, push, topChar, toStringcontains, containsAll, containsAll, toCharArrayfinalize, getClass, notify, notifyAll, wait, wait, waitadd, add, add, add, addAll, addAll, addAll, addElements, addElements, contains, get, indexOf, iterator, lastIndexOf, listIterator, of, of, of, remove, remove, removeChar, removeElements, replaceAll, replaceAll, replaceAll, set, set, setElements, setElements, setElements, size, sort, sort, unstableSort, unstableSortaddAll, addAll, clear, containsAll, hashCode, removeAll, retainAll, toArray, toArrayaddAll, contains, containsAll, intIterator, intParallelStream, intSpliterator, intStream, parallelStream, rem, removeAll, removeIf, removeIf, removeIf, retainAll, stream, toCharArrayforEach, forEachpublic CharImmutableList(char[] a)
Note that this constructor does not perform a defensive copy.
a - the array that will be used to back this immutable list.public CharImmutableList(java.util.Collection<? extends java.lang.Character> c)
c - a collection that will be used to fill the immutable list.public CharImmutableList(CharCollection c)
c - a type-specific collection that will be used to fill the immutable list.public CharImmutableList(CharList l)
l - a type-specific list that will be used to fill the immutable list.public CharImmutableList(char[] a,
int offset,
int length)
a - an array whose elements will be used to fill the immutable list.offset - the first element to use.length - the number of elements to use.public CharImmutableList(it.unimi.dsi.fastutil.chars.CharIterator i)
i - a type-specific iterator whose returned elements will fill the immutable list.public static CharImmutableList of()
public static CharImmutableList of(char... init)
Note that this method does not perform a defensive copy.
public char getChar(int index)
CharListpublic int indexOf(char k)
CharListindexOf in interface CharListindexOf in class AbstractCharListList.indexOf(Object)public int lastIndexOf(char k)
CharListlastIndexOf in interface CharListlastIndexOf in class AbstractCharListList.lastIndexOf(Object)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 boolean isEmpty()
isEmpty in interface it.unimi.dsi.fastutil.Stack<java.lang.Character>isEmpty in interface java.util.Collection<java.lang.Character>isEmpty in interface java.util.List<java.lang.Character>isEmpty in class java.util.AbstractCollection<java.lang.Character>public void getElements(int from,
char[] a,
int offset,
int length)
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 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 char[] toCharArray()
CharCollectiontoCharArray in interface CharCollectiontoCharArray in class AbstractCharListCollection.toArray()public char[] toArray(char[] a)
CharCollectionNote that, contrarily to Collection.toArray(Object[]), this
methods just writes all elements of this collection: no special
value will be added after the last one.
toArray in interface CharCollectiontoArray in class AbstractCharLista - if this array is big enough, it will be used to store this collection.Collection.toArray(Object[])public CharListIterator listIterator(int index)
AbstractCharListlistIterator in interface CharListlistIterator in interface java.util.List<java.lang.Character>listIterator in class AbstractCharListList.listIterator(int)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 CharList subList(int from, int to)
from, 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)public CharImmutableList clone()
clone in class java.lang.Objectpublic boolean equals(CharImmutableList l)
l - a type-specific immutable list.public boolean equals(java.lang.Object o)
equals in interface java.util.Collection<java.lang.Character>equals in interface java.util.List<java.lang.Character>equals in class AbstractCharListpublic int compareTo(CharImmutableList l)
l - an immutable list.public int compareTo(java.util.List<? extends java.lang.Character> l)
AbstractCharListList, this method performs a lexicographical comparison; otherwise,
it throws a ClassCastException.compareTo in interface java.lang.Comparable<java.util.List<? extends java.lang.Character>>compareTo in class AbstractCharListl - a list.List, a negative integer,
zero, or a positive integer as this list is lexicographically less than, equal
to, or greater than the argument.@Deprecated
public final void add(int index,
char k)
AbstractCharListadd in interface CharListadd in class AbstractCharListList.add(int,Object)@Deprecated public final boolean add(char k)
AbstractCharListadd in interface CharCollectionadd in interface CharListadd in class AbstractCharListCollection.add(Object)@Deprecated public final 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 AbstractCharList@Deprecated
public final boolean addAll(int index,
java.util.Collection<? extends java.lang.Character> c)
AbstractCharListaddAll in interface java.util.List<java.lang.Character>addAll in class AbstractCharList@Deprecated public final char removeChar(int index)
AbstractCharListremoveChar in interface CharListremoveChar in class AbstractCharListList.remove(int)@Deprecated public final boolean rem(char k)
AbstractCharListrem in interface CharCollectionrem in class AbstractCharListList.remove(Object)@Deprecated public final 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 AbstractCharCollection@Deprecated public final 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 final boolean removeIf(java.util.function.Predicate<? super java.lang.Character> c)
CharCollectionremoveIf in interface CharCollectionremoveIf in interface java.util.Collection<java.lang.Character>@Deprecated public final boolean removeIf(CharPredicate c)
CharCollectionremoveIf in interface CharCollectionc - a predicate which returns true for elements to be
removed.true if any elements were removed.Collection.removeIf(java.util.function.Predicate)@Deprecated public final void replaceAll(java.util.function.UnaryOperator<java.lang.Character> operator)
CharListreplaceAll in interface CharListreplaceAll in interface java.util.List<java.lang.Character>@Deprecated public final void replaceAll(java.util.function.IntUnaryOperator operator)
CharListreplaceAll in interface CharListoperator - the operator to apply to each elementList.replaceAll(java.util.function.UnaryOperator<E>)@Deprecated
public final void add(int index,
java.lang.Character k)
CharList@Deprecated public final boolean add(java.lang.Character k)
AbstractCharCollectionadd in interface CharCollectionadd in interface CharListadd in interface java.util.Collection<java.lang.Character>add in interface java.util.List<java.lang.Character>add in class AbstractCharCollection@Deprecated public final java.lang.Character remove(int index)
CharList@Deprecated public final boolean remove(java.lang.Object k)
AbstractCharCollectionremove in interface CharCollectionremove in interface CharListremove in interface java.util.Collection<java.lang.Character>remove in interface java.util.List<java.lang.Character>remove in class AbstractCharCollection@Deprecated
public final java.lang.Character set(int index,
java.lang.Character k)
CharList@Deprecated public final 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)@Deprecated public final boolean addAll(CharList c)
CharList@Deprecated
public final boolean addAll(int index,
CharCollection c)
CharListaddAll in interface CharListaddAll in class AbstractCharListList.addAll(int,java.util.Collection)@Deprecated
public final boolean addAll(int index,
CharList c)
CharList@Deprecated public final 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)@Deprecated public final 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)@Deprecated
public final char set(int index,
char k)
AbstractCharListset in interface CharListset in class AbstractCharListList.set(int,Object)@Deprecated public final void clear()
AbstractCharListclear in interface java.util.Collection<java.lang.Character>clear in interface java.util.List<java.lang.Character>clear in class AbstractCharList@Deprecated public final 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.@Deprecated
public final 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).@Deprecated
public final 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.@Deprecated
public final 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.@Deprecated public final void sort(it.unimi.dsi.fastutil.chars.CharComparator comp)
CharListPass null to sort using natural ordering.
@Deprecated public final void unstableSort(it.unimi.dsi.fastutil.chars.CharComparator comp)
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 final void sort(java.util.Comparator<? super java.lang.Character> comparator)
CharList@Deprecated public final void unstableSort(java.util.Comparator<? super java.lang.Character> comparator)
CharListunstableSort in interface CharList