public static class CharLists.Singleton extends AbstractCharList implements RandomAccess, Serializable, Cloneable
This class may be useful to implement your own in case you subclass a type-specific list.
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(Collection<? extends Character> c)
Adds all of the elements in the specified collection to this collection
(optional operation).
|
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,
Collection<? extends Character> c)
Adds all of the elements in the specified collection to this list
(optional operation).
|
void |
clear()
Removes all of the elements from this collection (optional operation).
|
Object |
clone()
Creates and returns a copy of this object.
|
boolean |
contains(char k)
Returns true if this list contains the specified element.
|
char |
getChar(int i)
Returns the element at the specified position in this list.
|
CharListIterator |
iterator()
Returns an iterator over the elements contained in 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(Collection<?> c)
Removes all of this collection's elements that are also contained in the
specified collection (optional operation).
|
char |
removeChar(int i)
Removes the element at the specified position in this list (optional
operation).
|
boolean |
retainAll(CharCollection c)
Retains in this collection only elements from the given type-specific
collection.
|
boolean |
retainAll(Collection<?> c)
Retains only the elements in this collection that are contained in the
specified collection (optional operation).
|
int |
size()
Returns the number of elements in this collection.
|
void |
size(int size)
Sets the size 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[] |
toCharArray()
Returns a primitive type array containing the items of this collection.
|
add, add, add, addElements, addElements, compareTo, equals, get, getElements, hashCode, indexOf, indexOf, lastIndexOf, lastIndexOf, peek, peekChar, pop, popChar, push, push, remove, removeElements, set, set, top, topChar, toStringadd, contains, containsAll, remove, toArray, toCharArraycontainsAll, isEmpty, toArray, toArraycontains, containsAll, isEmpty, remove, replaceAll, sort, spliterator, toArray, toArraycontains, containsAll, remove, toArray, toCharArrayparallelStream, removeIf, streamforEach, forEachpublic char getChar(int i)
CharListgetChar in interface CharListList.get(int)public boolean rem(char k)
AbstractCharList
This implementation delegates to indexOf().
rem in interface CharCollectionrem in class AbstractCharListList.remove(Object)public char removeChar(int i)
AbstractCharList
This implementation always throws an
UnsupportedOperationException.
removeChar in interface CharListremoveChar in class AbstractCharListList.remove(int)public boolean contains(char k)
AbstractCharList
This implementation delegates to indexOf().
contains in interface CharCollectioncontains in class AbstractCharListList.contains(Object)public char[] toCharArray()
CharCollectiontoCharArray in interface CharCollectiontoCharArray in class AbstractCharCollectionCollection.toArray()public CharListIterator listIterator()
AbstractCharList
This implementation delegates to listIterator(0).
listIterator in interface CharListlistIterator in interface List<Character>listIterator in class AbstractCharListList.listIterator()public CharListIterator iterator()
AbstractCharList
This implementation delegates to AbstractCharList.listIterator().
iterator in interface CharCollectioniterator in interface CharIterableiterator in interface CharListiterator in interface Iterable<Character>iterator in interface Collection<Character>iterator in interface List<Character>iterator in class AbstractCharListIterable.iterator()public CharListIterator listIterator(int i)
AbstractCharListThis implementation is based on the random-access methods.
listIterator in interface CharListlistIterator in interface List<Character>listIterator in class AbstractCharListi - index of the first element to be returned from the
list iterator (by a call to next)List.listIterator(int)public CharList subList(int from, int to)
CharListfrom, inclusive, to the index to, exclusive.
Note that this specification strengthens the one given in
List.subList(int,int).
subList in interface CharListsubList in interface List<Character>subList in class AbstractCharListfrom - low endpoint (inclusive) of the subListto - high endpoint (exclusive) of the subListList.subList(int,int)public boolean addAll(int i,
Collection<? extends Character> c)
AbstractCharListaddAll in interface List<Character>addAll in class AbstractCharListi - index at which to insert the first element from the
specified collectionc - collection containing elements to be added to this listpublic boolean addAll(Collection<? extends Character> c)
AbstractCharListThis implementation iterates over the specified collection, and adds each object returned by the iterator to this collection, in turn.
Note that this implementation will throw an UnsupportedOperationException unless add is overridden (assuming the specified collection is non-empty).
This implementation delegates to the type-specific version of
List.addAll(int, Collection).
addAll in interface Collection<Character>addAll in interface List<Character>addAll in class AbstractCharListc - collection containing elements to be added to this collectionAbstractCollection.add(Object)public boolean removeAll(Collection<?> c)
java.util.AbstractCollectionThis implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's so contained, it's removed from this collection with the iterator's remove method.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements in common with the specified collection.
removeAll in interface Collection<Character>removeAll in interface List<Character>removeAll in class AbstractCollection<Character>c - collection containing elements to be removed from this collectionAbstractCollection.remove(Object),
AbstractCollection.contains(Object)public boolean retainAll(Collection<?> c)
java.util.AbstractCollectionThis implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's not so contained, it's removed from this collection with the iterator's remove method.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements not present in the specified collection.
retainAll in interface Collection<Character>retainAll in interface List<Character>retainAll in class AbstractCollection<Character>c - collection containing elements to be retained in this collectionAbstractCollection.remove(Object),
AbstractCollection.contains(Object)public boolean addAll(CharList c)
AbstractCharList
This implementation delegates to the type-specific list version of
List.addAll(int, Collection).
addAll in interface CharListaddAll in class AbstractCharListList.add(int,Object)public boolean addAll(int i,
CharList c)
AbstractCharList
This implementation delegates to the type-specific version of
List.addAll(int, Collection).
addAll in interface CharListaddAll in class AbstractCharListList.add(int,Object)public boolean addAll(int i,
CharCollection c)
CharListaddAll in interface CharListaddAll in class AbstractCharListList.addAll(int,java.util.Collection)public boolean addAll(CharCollection c)
AbstractCharList
This implementation delegates to the type-specific version of
List.addAll(int, Collection).
addAll 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 int size()
java.util.Collectionsize in interface Collection<Character>size in interface List<Character>size in class AbstractCollection<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 CharListsize in class AbstractCharListsize - the new size.public void clear()
AbstractCharListThis implementation iterates over this collection, removing each element using the Iterator.remove operation. Most implementations will probably choose to override this method for efficiency.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by this collection's iterator method does not implement the remove method and this collection is non-empty.
This implementation delegates to AbstractCharList.removeElements(int, int).
clear in interface Collection<Character>clear in interface List<Character>clear in class AbstractCharListpublic Object clone()
java.lang.Objectx, the expression:
will be true, and that the expression:x.clone() != x
will bex.clone().getClass() == x.getClass()
true, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x)
true, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
super.clone. If a class and all of its superclasses (except
Object) obey this convention, it will be the case that
x.clone().getClass() == x.getClass().
By convention, the object returned by this method should be independent
of this object (which is being cloned). To achieve this independence,
it may be necessary to modify one or more fields of the object returned
by super.clone before returning it. Typically, this means
copying any mutable objects that comprise the internal "deep structure"
of the object being cloned and replacing the references to these
objects with references to the copies. If a class contains only
primitive fields or references to immutable objects, then it is usually
the case that no fields in the object returned by super.clone
need to be modified.
The method clone for class Object performs a
specific cloning operation. First, if the class of this object does
not implement the interface Cloneable, then a
CloneNotSupportedException is thrown. Note that all arrays
are considered to implement the interface Cloneable and that
the return type of the clone method of an array type T[]
is T[] where T is any reference or primitive type.
Otherwise, this method creates a new instance of the class of this
object and initializes all its fields with exactly the contents of
the corresponding fields of this object, as if by assignment; the
contents of the fields are not themselves cloned. Thus, this method
performs a "shallow copy" of this object, not a "deep copy" operation.
The class Object does not itself implement the interface
Cloneable, so calling the clone method on an object
whose class is Object will result in throwing an
exception at run time.