public interface CharList extends PrimitiveList<Character>, CharCollection
char
values.
This interface extends List
allowing seamless integration
with other APIs.
All List methods can be used, using the primitive wrapper class Character
.
However, it will be much more efficient to use the methods defined here.
Modifier and Type | Method and Description |
---|---|
boolean |
add(int index,
char value)
Adds a primitive value to this list at an index (optional operation).
|
boolean |
addAll(int index,
char[] values)
Adds an array of primitive values to this list at an index (optional operation).
|
char |
firstChar()
Gets the first primitive value.
|
char |
getChar(int index)
Gets the primitive value at the specified index.
|
int |
indexOf(char value)
Gets the first index of the specified primitive value.
|
int |
indexOf(char value,
int fromIndexInclusive)
Gets the first index of the specified primitive value from an index.
|
CharIterator |
iterator()
Gets an iterator over this list capable of accessing the primitive values.
|
char |
lastChar()
Gets the last primitive value.
|
int |
lastIndexOf(char value)
Gets the last index of the specified primitive value.
|
int |
lastIndexOf(char value,
int fromIndexInclusive)
Gets the first index of the specified primitive value from an index.
|
CharListIterator |
listIterator()
Gets a list iterator over this list capable of accessing the primitive values.
|
CharListIterator |
listIterator(int index)
Gets a list iterator over this list from a start index capable of accessing the primitive values.
|
Character |
remove(int index)
Deprecated.
use char removeCharAt(int)
|
char |
removeCharAt(int index)
Removes a primitive value by index from the list (optional operation).
|
char |
set(int index,
char value)
Sets the primitive value at a specified index (optional operation).
|
CharList |
subList(int fromIndexInclusive,
int toIndexExclusive)
Gets a range view of part of this list.
|
char[] |
toCharArray(int fromIndexInclusive,
int toIndexExclusive)
Gets a range of elements as an array.
|
String |
toStringContents()
Gets the contents of the list as a String.
|
first, last, removeRange
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, lastIndexOf, remove, removeAll, retainAll, set, size, toArray, toArray
add, addAll, addAll, addAll, contains, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, toCharArray, toCharArray
containsAny
clear, clone, isEmpty, isModifiable, optimize, size
CharIterator iterator()
iterator
in interface CharCollection
iterator
in interface CharIterable
iterator
in interface Collection<Character>
iterator
in interface Iterable<Character>
iterator
in interface List<Character>
char getChar(int index)
index
- the index to get fromIndexOutOfBoundsException
- if the index is invalidchar firstChar()
IndexOutOfBoundsException
- if the size is zerochar lastChar()
size() - 1
IndexOutOfBoundsException
- if the size is zeroCharListIterator listIterator()
listIterator
in interface List<Character>
CharListIterator listIterator(int index)
listIterator
in interface List<Character>
index
- the index to start fromIndexOutOfBoundsException
- if the index is invalidint indexOf(char value)
value
- the value to search for-1
if not foundint indexOf(char value, int fromIndexInclusive)
This method follows the conventions of String
in that a
negative index is treated as zero, and an index greater than the list
size will simply return -1
.
value
- the value to search forfromIndexInclusive
- the index to start searching from, inclusive-1
if not foundint lastIndexOf(char value)
value
- the value to search for-1
if not foundint lastIndexOf(char value, int fromIndexInclusive)
This method follows the conventions of String
in that an
index greater than the list size will start searching at the list size,
and a negative index simply returns -1
.
value
- the value to search forfromIndexInclusive
- the index to start searching from, inclusive-1
if not foundString toStringContents()
char[] toCharArray(int fromIndexInclusive, int toIndexExclusive)
fromIndexInclusive
- the index to start from, inclusivetoIndexExclusive
- the index to end at, exclusiveIndexOutOfBoundsException
- if either index is invalidCharList subList(int fromIndexInclusive, int toIndexExclusive)
This method allows operations to work on a range within the greater list. Changes made to the either object will affect the other.
subList
in interface List<Character>
fromIndexInclusive
- the index to start from, inclusivetoIndexExclusive
- the index to end at, exclusiveIndexOutOfBoundsException
- if either index is invalidboolean add(int index, char value)
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
index
- the index to add atvalue
- the value to add to this collectiontrue
if this list was modified by this method callIndexOutOfBoundsException
- if the index is invalidIllegalArgumentException
- if value is rejected by this collectionUnsupportedOperationException
- if not supported by this collectionboolean addAll(int index, char[] values)
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
index
- the index to add atvalues
- the values to add to this collection, null treated as empty arraytrue
if this list was modified by this method callIndexOutOfBoundsException
- if the index is invalidIllegalArgumentException
- if value is rejected by this collectionUnsupportedOperationException
- if not supported by this collection@Deprecated Character remove(int index)
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This method is deprecated to serve as a warning to developers.
Using it can be confusing as it removes by index rather than by primitive.
The method will still function correctly as the method is defined in the List interface.
Use removeCharAt(int)
instead.
remove
in interface List<Character>
index
- the index to remove fromIndexOutOfBoundsException
- if the index is invalidUnsupportedOperationException
- if not supported by this collectionchar removeCharAt(int index)
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
index
- the index to remove fromIndexOutOfBoundsException
- if the index is invalidUnsupportedOperationException
- if not supported by this collectionchar set(int index, char value)
This method is optional, throwing an UnsupportedOperationException if the collection cannot be changed.
index
- the index to setvalue
- the value to storeIndexOutOfBoundsException
- if the index is invalidIllegalArgumentException
- if value is rejected by this collectionUnsupportedOperationException
- if not supported by this collectionCopyright © 2005-2012 Joda.org. All Rights Reserved.