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 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(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.
|
IntIterator |
intIterator()
Returns a widened primitive iterator on the elements of this collection.
|
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(CharComparator comparator)
Sort a list using a type-specific comparator.
|
void |
sort(java.util.Comparator<? super java.lang.Character> comparator)
Deprecated.
|
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(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, equals, hashCode, lastIndexOf, peekChar, popChar, push, set, toArray, topChar, toString
add, contains, containsAll, containsAll, remove, toCharArray
add, add, contains, get, indexOf, lastIndexOf, of, of, of, of, of, remove, remove, replaceAll, set
containsAll, intParallelStream, intStream, parallelStream, removeIf, stream, toCharArray
forEach
public char getChar(int i)
CharList
public boolean rem(char k)
AbstractCharList
rem
in interface CharCollection
rem
in class AbstractCharList
List.remove(Object)
public char removeChar(int i)
AbstractCharList
removeChar
in interface CharList
removeChar
in class AbstractCharList
List.remove(int)
public boolean contains(char k)
AbstractCharList
contains
in interface CharCollection
contains
in class AbstractCharList
List.contains(Object)
public int indexOf(char k)
CharList
indexOf
in interface CharList
indexOf
in class AbstractCharList
List.indexOf(Object)
public char[] toCharArray()
CharCollection
toCharArray
in interface CharCollection
toCharArray
in class AbstractCharList
Collection.toArray()
public CharListIterator listIterator()
AbstractCharList
listIterator
in interface CharList
listIterator
in interface java.util.List<java.lang.Character>
listIterator
in class AbstractCharList
List.listIterator()
public CharListIterator iterator()
AbstractCharList
iterator
in interface CharCollection
iterator
in interface CharIterable
iterator
in interface CharList
iterator
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 AbstractCharList
Iterable.iterator()
public CharSpliterator spliterator()
CharList
List 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 CharCollection
spliterator
in interface CharIterable
spliterator
in interface CharList
spliterator
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)
AbstractCharList
listIterator
in interface CharList
listIterator
in interface java.util.List<java.lang.Character>
listIterator
in class AbstractCharList
List.listIterator(int)
public CharList subList(int from, int to)
CharList
from
, inclusive, to the index to
, exclusive.subList
in interface CharList
subList
in interface java.util.List<java.lang.Character>
subList
in class AbstractCharList
List.subList(int,int)
@Deprecated public void forEach(java.util.function.Consumer<? super java.lang.Character> action)
CharIterable
forEach
in interface CharIterable
forEach
in interface java.lang.Iterable<java.lang.Character>
public boolean addAll(int i, java.util.Collection<? extends java.lang.Character> c)
AbstractCharList
addAll
in interface java.util.List<java.lang.Character>
addAll
in class AbstractCharList
public boolean addAll(java.util.Collection<? extends java.lang.Character> c)
AbstractCharList
addAll
in interface java.util.Collection<java.lang.Character>
addAll
in interface java.util.List<java.lang.Character>
addAll
in class AbstractCharList
public boolean removeAll(java.util.Collection<?> c)
AbstractCharCollection
removeAll
in interface java.util.Collection<java.lang.Character>
removeAll
in interface java.util.List<java.lang.Character>
removeAll
in class AbstractCharCollection
public boolean retainAll(java.util.Collection<?> c)
AbstractCharCollection
retainAll
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)
CharCollection
removeIf
in interface CharCollection
removeIf
in interface java.util.Collection<java.lang.Character>
@Deprecated public void replaceAll(java.util.function.UnaryOperator<java.lang.Character> operator)
CharList
replaceAll
in interface CharList
replaceAll
in interface java.util.List<java.lang.Character>
public void replaceAll(CharUnaryOperator operator)
CharList
replaceAll
in interface CharList
operator
- the operator to apply to each element.List.replaceAll(java.util.function.UnaryOperator<E>)
public void forEach(CharConsumer action)
AbstractCharList
Iterable
until all elements have been processed or the action throws an
exception.forEach
in interface CharIterable
forEach
in class AbstractCharList
action
- the action to be performed for each element.Iterable.forEach(java.util.function.Consumer)
public boolean addAll(CharList c)
CharList
public boolean addAll(int i, CharList c)
CharList
public boolean addAll(int i, CharCollection c)
CharList
addAll
in interface CharList
addAll
in class AbstractCharList
List.addAll(int,java.util.Collection)
public boolean addAll(CharCollection c)
AbstractCharList
addAll
in interface CharCollection
addAll
in class AbstractCharList
c
- a type-specific collection.true
if this collection changed as a result of the call.Collection.addAll(Collection)
public boolean removeAll(CharCollection c)
CharCollection
removeAll
in interface CharCollection
removeAll
in class AbstractCharCollection
c
- a type-specific collection.true
if this collection changed as a result of the call.Collection.removeAll(Collection)
public boolean retainAll(CharCollection c)
CharCollection
retainAll
in interface CharCollection
retainAll
in class AbstractCharCollection
c
- a type-specific collection.true
if this collection changed as a result of the call.Collection.retainAll(Collection)
public boolean removeIf(CharPredicate filter)
CharCollection
removeIf
in interface CharCollection
filter
- a predicate which returns true
for elements to be
removed.true
if any elements were removed.Collection.removeIf(java.util.function.Predicate)
public 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 CharCollection
intIterator
in interface CharIterable
public 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 CharCollection
intSpliterator
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(CharComparator comparator)
CharList
Pass null
to sort using natural ordering.
public void unstableSort(CharComparator comparator)
CharList
Pass 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)
CharList
unstableSort
in interface CharList
public void getElements(int from, char[] a, int offset, int length)
AbstractCharList
This is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.
getElements
in interface CharList
getElements
in class AbstractCharList
from
- 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)
AbstractCharList
This is a trivial iterator-based based implementation. It is expected that implementations will override this method with a more optimized version.
removeElements
in interface CharList
removeElements
in class AbstractCharList
from
- the start index (inclusive).to
- the end index (exclusive).public void addElements(int index, char[] a)
AbstractCharList
addElements
in interface CharList
addElements
in class AbstractCharList
index
- the index at which to add elements.a
- the array containing the elements.public void addElements(int index, char[] a, int offset, int length)
AbstractCharList
This is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.
addElements
in interface CharList
addElements
in class AbstractCharList
index
- 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)
CharList
setElements
in interface CharList
a
- the array containing the elements.public void setElements(int index, char[] a)
CharList
setElements
in interface CharList
index
- 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 CharList
setElements
in class AbstractCharList
index
- 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)
CharList
If 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 CharList
size
in class AbstractCharList
size
- the new size.public void clear()
AbstractCharList
clear
in interface java.util.Collection<java.lang.Character>
clear
in interface java.util.List<java.lang.Character>
clear
in class AbstractCharList
public java.lang.Object clone()
clone
in class java.lang.Object