Class AbstractCharList
- java.lang.Object
-
- java.util.AbstractCollection<Character>
-
- org.codelibs.jhighlight.fastutil.chars.AbstractCharCollection
-
- org.codelibs.jhighlight.fastutil.chars.AbstractCharList
-
- All Implemented Interfaces:
Comparable<List<? extends Character>>,Iterable<Character>,Collection<Character>,List<Character>,CharCollection,CharIterable,CharList,CharStack,Stack<Character>
- Direct Known Subclasses:
AbstractCharList.CharSubList,CharArrayList
public abstract class AbstractCharList extends AbstractCharCollection implements CharList, CharStack
An abstract class providing basic methods for lists implementing a type-specific list interface.As an additional bonus, this class implements on top of the list operations a type-specific stack.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractCharList.CharSubList
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractCharList()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanadd(char k)voidadd(int index, char k)voidadd(int index, Character ok)Delegates to the corresponding type-specific method.booleanaddAll(int index, Collection<? extends Character> c)booleanaddAll(int index, CharCollection c)Delegates to a more generic method.booleanaddAll(int index, CharList l)Delegates to a more generic method.booleanaddAll(Collection<? extends Character> c)Delegates to a more generic method.booleanaddAll(CharCollection c)Adds all elements of the given type-specific collection to this collection.booleanaddAll(CharList l)voidaddElements(int index, char[] a)Add (hopefully quickly) elements to this type-specific list.voidaddElements(int index, char[] a, int offset, int length)Adds elements to this type-specific list one-by-one.CharListIteratorcharListIterator()Deprecated.CharListIteratorcharListIterator(int index)Deprecated.CharListcharSubList(int from, int to)Deprecated.intcompareTo(List<? extends Character> l)Compares this list to another object.booleancontains(char k)protected voidensureIndex(int index)Ensures that the given index is nonnegative and not greater than the list size.protected voidensureRestrictedIndex(int index)Ensures that the given index is nonnegative and smaller than the list size.booleanequals(Object o)Characterget(int index)Delegates to the corresponding type-specific method.voidgetElements(int from, char[] a, int offset, int length)Copies element of this type-specific list into the given array one-by-one.inthashCode()Returns the hash code for this list, which is identical toList.hashCode().intindexOf(char k)intindexOf(Object ok)Delegates to the corresponding type-specific method.CharListIteratoriterator()Returns a type-specific iterator on the elements of this collection.intlastIndexOf(char k)intlastIndexOf(Object ok)Delegates to the corresponding type-specific method.CharListIteratorlistIterator()Returns a type-specific list iterator on the list.CharListIteratorlistIterator(int index)Returns a type-specific list iterator on the list starting at a given index.Characterpeek(int i)Delegates to the corresponding type-specific method.charpeekChar(int i)Characterpop()Delegates to the corresponding type-specific method.charpopChar()voidpush(char o)voidpush(Character o)Delegates to the corresponding type-specific method.booleanrem(char k)Characterremove(int index)Delegates to the corresponding type-specific method.booleanremove(Object o)Delegates torem().charremoveChar(int i)voidremoveElements(int from, int to)Removes elements of this type-specific list one-by-one.charset(int index, char k)Characterset(int index, Character ok)Delegates to the corresponding type-specific method.voidsize(int size)Sets the size of this list.CharListsubList(int from, int to)Returns a type-specific view of the portion of this list from the indexfrom, inclusive, to the indexto, exclusive.Charactertop()Delegates to the corresponding type-specific method.chartopChar()StringtoString()-
Methods inherited from class org.codelibs.jhighlight.fastutil.chars.AbstractCharCollection
add, charIterator, contains, containsAll, containsAll, isEmpty, rem, removeAll, removeAll, retainAll, retainAll, toArray, toArray, toArray, toCharArray, toCharArray
-
Methods inherited from class java.util.AbstractCollection
clear, size
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.codelibs.jhighlight.fastutil.chars.CharCollection
charIterator, containsAll, removeAll, retainAll, toArray, toArray, toCharArray, toCharArray
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
add, clear, contains, containsAll, isEmpty, removeAll, replaceAll, retainAll, size, sort, spliterator, toArray, toArray
-
-
-
-
Method Detail
-
ensureIndex
protected void ensureIndex(int index)
Ensures that the given index is nonnegative and not greater than the list size.- Parameters:
index- an index.- Throws:
IndexOutOfBoundsException- if the given index is negative or greater than the list size.
-
ensureRestrictedIndex
protected void ensureRestrictedIndex(int index)
Ensures that the given index is nonnegative and smaller than the list size.- Parameters:
index- an index.- Throws:
IndexOutOfBoundsException- if the given index is negative or not smaller than the list size.
-
add
public void add(int index, char k)- Specified by:
addin interfaceCharList- See Also:
List.add(int,Object)
-
add
public boolean add(char k)
- Specified by:
addin interfaceCharCollection- Specified by:
addin interfaceCharList- Overrides:
addin classAbstractCharCollection- See Also:
Collection.add(Object)
-
removeChar
public char removeChar(int i)
- Specified by:
removeCharin interfaceCharList- See Also:
List.remove(int)
-
set
public char set(int index, char k)- Specified by:
setin interfaceCharList- See Also:
List.set(int,Object)
-
addAll
public boolean addAll(int index, Collection<? extends Character> c)
-
addAll
public boolean addAll(Collection<? extends Character> c)
Delegates to a more generic method.- Specified by:
addAllin interfaceCollection<Character>- Specified by:
addAllin interfaceList<Character>- Overrides:
addAllin classAbstractCharCollection- Parameters:
c- a collection.- Returns:
trueif this collection changed as a result of the call.
-
charListIterator
@Deprecated public CharListIterator charListIterator()
Deprecated.Delegates to the new covariantly stronger generic method.- Specified by:
charListIteratorin interfaceCharList- See Also:
CharList.listIterator()
-
charListIterator
@Deprecated public CharListIterator charListIterator(int index)
Deprecated.Delegates to the new covariantly stronger generic method.- Specified by:
charListIteratorin interfaceCharList- See Also:
CharList.listIterator(int)
-
iterator
public CharListIterator iterator()
Description copied from interface:CharCollectionReturns 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.- Specified by:
iteratorin interfaceCharCollection- Specified by:
iteratorin interfaceCharIterable- Specified by:
iteratorin interfaceCharList- Specified by:
iteratorin interfaceCollection<Character>- Specified by:
iteratorin interfaceIterable<Character>- Specified by:
iteratorin interfaceList<Character>- Specified by:
iteratorin classAbstractCharCollection- Returns:
- a type-specific iterator on the elements of this collection.
-
listIterator
public CharListIterator listIterator()
Description copied from interface:CharListReturns a type-specific list iterator on the list.- Specified by:
listIteratorin interfaceCharList- Specified by:
listIteratorin interfaceList<Character>- See Also:
List.listIterator()
-
listIterator
public CharListIterator listIterator(int index)
Description copied from interface:CharListReturns a type-specific list iterator on the list starting at a given index.- Specified by:
listIteratorin interfaceCharList- Specified by:
listIteratorin interfaceList<Character>- See Also:
List.listIterator(int)
-
contains
public boolean contains(char k)
- Specified by:
containsin interfaceCharCollection- Overrides:
containsin classAbstractCharCollection- See Also:
Collection.contains(Object)
-
indexOf
public int indexOf(char k)
- Specified by:
indexOfin interfaceCharList- See Also:
List.indexOf(Object)
-
lastIndexOf
public int lastIndexOf(char k)
- Specified by:
lastIndexOfin interfaceCharList- See Also:
List.lastIndexOf(Object)
-
size
public void size(int size)
Description copied from interface:CharListSets 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.
-
subList
public CharList subList(int from, int to)
Description copied from interface:CharListReturns 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).
-
charSubList
@Deprecated public CharList charSubList(int from, int to)
Deprecated.Delegates to the new covariantly stronger generic method.- Specified by:
charSubListin interfaceCharList- See Also:
List.subList(int,int)
-
removeElements
public void removeElements(int from, int to)Removes elements of this type-specific list one-by-one.This is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.
- Specified by:
removeElementsin interfaceCharList- Parameters:
from- the start index (inclusive).to- the end index (exclusive).
-
addElements
public void addElements(int index, char[] a, int offset, int length)Adds elements to this type-specific list one-by-one.This is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.
- Specified by:
addElementsin interfaceCharList- Parameters:
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.
-
addElements
public void addElements(int index, char[] a)Description copied from interface:CharListAdd (hopefully quickly) elements to this type-specific list.- Specified by:
addElementsin interfaceCharList- Parameters:
index- the index at which to add elements.a- the array containing the elements.
-
getElements
public void getElements(int from, char[] a, int offset, int length)Copies element of this type-specific list into the given array one-by-one.This is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.
- Specified by:
getElementsin interfaceCharList- Parameters:
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.
-
equals
public boolean equals(Object o)
-
compareTo
public int compareTo(List<? extends Character> l)
Compares this list to another object. If the argument is aList, this method performs a lexicographical comparison; otherwise, it throws aClassCastException.- Specified by:
compareToin interfaceComparable<List<? extends Character>>- Parameters:
l- a list.- Returns:
- if the argument is a
List, a negative integer, zero, or a positive integer as this list is lexicographically less than, equal to, or greater than the argument. - Throws:
ClassCastException- if the argument is not a list.
-
hashCode
public int hashCode()
Returns the hash code for this list, which is identical toList.hashCode().
-
push
public void push(char o)
- Specified by:
pushin interfaceCharStack- See Also:
Stack.push(Object)
-
popChar
public char popChar()
- Specified by:
popCharin interfaceCharStack- See Also:
Stack.pop()
-
topChar
public char topChar()
- Specified by:
topCharin interfaceCharStack- See Also:
Stack.top()
-
peekChar
public char peekChar(int i)
- Specified by:
peekCharin interfaceCharStack- See Also:
Stack.peek(int)
-
rem
public boolean rem(char k)
Description copied from interface:CharCollectionNote that this method should be calledremove(), but the clash with the similarly named index-based method in theListinterface forces us to use a distinguished name. For simplicity, the set interfaces reinstatesremove().- Specified by:
remin interfaceCharCollection- Overrides:
remin classAbstractCharCollection- See Also:
Collection.remove(Object)
-
remove
public boolean remove(Object o)
Delegates torem().- Specified by:
removein interfaceCollection<Character>- Specified by:
removein interfaceList<Character>- Overrides:
removein classAbstractCharCollection
-
addAll
public boolean addAll(int index, CharCollection c)Delegates to a more generic method.- Specified by:
addAllin interfaceCharList- See Also:
List.add(int,Object)
-
addAll
public boolean addAll(int index, CharList l)Delegates to a more generic method.- Specified by:
addAllin interfaceCharList- See Also:
List.add(int,Object)
-
addAll
public boolean addAll(CharCollection c)
Description copied from class:AbstractCharCollectionAdds all elements of the given type-specific collection to this collection.- Specified by:
addAllin interfaceCharCollection- Overrides:
addAllin classAbstractCharCollection- Parameters:
c- a type-specific collection.- Returns:
trueif this collection changed as a result of the call.- See Also:
Collection.addAll(Collection)
-
addAll
public boolean addAll(CharList l)
- Specified by:
addAllin interfaceCharList- See Also:
List.add(int,Object)
-
add
public void add(int index, Character ok)Delegates to the corresponding type-specific method.
-
set
public Character set(int index, Character ok)
Delegates to the corresponding type-specific method.
-
get
public Character get(int index)
Delegates to the corresponding type-specific method.
-
indexOf
public int indexOf(Object ok)
Delegates to the corresponding type-specific method.
-
lastIndexOf
public int lastIndexOf(Object ok)
Delegates to the corresponding type-specific method.- Specified by:
lastIndexOfin interfaceList<Character>
-
remove
public Character remove(int index)
Delegates to the corresponding type-specific method.
-
push
public void push(Character o)
Delegates to the corresponding type-specific method.
-
pop
public Character pop()
Delegates to the corresponding type-specific method.
-
top
public Character top()
Delegates to the corresponding type-specific method.
-
peek
public Character peek(int i)
Delegates to the corresponding type-specific method.
-
toString
public String toString()
- Overrides:
toStringin classAbstractCharCollection
-
-