public class CharGapList
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Note that this implementation is not synchronized.
GapList,
CharObjGapList,
Serialized Form| Constructor and Description |
|---|
CharGapList()
Default constructor.
|
CharGapList(char... that)
Copy constructor.
|
CharGapList(java.util.Collection<java.lang.Character> that)
Copy constructor.
|
CharGapList(int capacity)
Construct a list with specified capacity.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(char elem) |
void |
add(int index,
char elem) |
boolean |
addAll(char... elems)
Adds all specified elements into this list.
|
boolean |
addAll(CharGapList list)
Adds all of the elements in the specified list into this list.
|
boolean |
addAll(java.util.Collection<java.lang.Character> coll)
Adds all of the elements in the specified collection into this list.
|
boolean |
addAll(int index,
char... elems)
Inserts the specified elements into this list,
starting at the specified position.
|
boolean |
addAll(int index,
CharGapList list)
Inserts all of the elements in the specified list into this
list, starting at the specified position.
|
boolean |
addAll(int index,
java.util.Collection<java.lang.Character> coll)
Inserts all of the elements in the specified collection into this
list, starting at the specified position.
|
void |
addFirst(char elem) |
void |
addLast(char elem) |
int |
binarySearch(char key)
Searches the specified range for an object using the binary
search algorithm.
|
int |
binarySearch(int index,
int len,
char key)
Searches the specified range for an object using the binary
search algorithm.
|
int |
capacity()
Returns capacity of this CharGapList.
|
void |
clear() |
java.lang.Object |
clone()
Returns a shallow copy of this CharGapList instance
(The elements themselves are not copied).
|
boolean |
contains(char elem) |
boolean |
containsAll(java.util.Collection<java.lang.Character> coll) |
boolean |
containsAny(java.util.Collection<java.lang.Character> coll)
Returns true if any of the elements of the specified collection is contained in the list.
|
CharGapList |
copy()
Returns a shallow copy of this CharGapList instance
(the new list will contain the same elements as the source list, i.e. the elements themselves are not copied).
|
static void |
copy(CharGapList src,
int srcIndex,
CharGapList dst,
int dstIndex,
int len)
Copies elements from one CharGapList to another.
|
void |
copy(int srcIndex,
int dstIndex,
int len)
Copy specified elements.
|
static CharGapList |
create()
Create new list.
|
static CharGapList |
create(char... elems)
Create new list with specified elements.
|
static CharGapList |
create(java.util.Collection<java.lang.Character> coll)
Create new list with specified elements.
|
static CharGapList |
create(int capacity)
Create new list with specified capacity.
|
char |
element() |
static CharGapList |
EMPTY() |
void |
ensureCapacity(int minCapacity)
Increases the capacity of this CharGapList instance, if
necessary, to ensure that it can hold at least the number of elements
specified by the minimum capacity argument.
|
boolean |
equals(java.lang.Object obj) |
void |
fill(char elem)
Fill list.
|
void |
fill(int index,
int len,
char elem)
Fill specified elements.
|
char |
get(int index) |
CharGapList |
getAll(int index,
int len)
Returns specified range of elements from list.
|
char[] |
getArray(int index,
int len)
Returns specified range of elements from list.
|
char |
getFirst() |
char |
getLast() |
int |
hashCode() |
int |
indexOf(char elem) |
void |
init()
Initialize the list to be empty.
|
void |
init(char... elems)
Initialize the list to contain the specified elements only.
|
void |
init(java.util.Collection<java.lang.Character> coll)
Initialize the list to contain the specified elements only.
|
void |
init(int capacity)
Initialize the list to be empty with specified capacity.
|
void |
init(int len,
char elem)
Initializes the list so it will afterwards have a size of
len and contain only the element elem. |
boolean |
isEmpty() |
int |
lastIndexOf(char elem) |
static void |
move(CharGapList src,
int srcIndex,
CharGapList dst,
int dstIndex,
int len)
Moves elements from one CharGapList to another.
|
void |
move(int srcIndex,
int dstIndex,
int len)
Move specified elements.
|
boolean |
offer(char elem) |
boolean |
offerFirst(char elem) |
boolean |
offerLast(char elem) |
char |
peek() |
char |
peekFirst() |
char |
peekLast() |
char |
poll() |
char |
pollFirst() |
char |
pollLast() |
char |
pop() |
void |
push(char elem) |
char |
remove() |
char |
remove(int index) |
void |
remove(int index,
int len)
Remove specified range of elements from list.
|
boolean |
removeAll(CharGapList coll) |
boolean |
removeAll(java.util.Collection<java.lang.Character> coll) |
char |
removeFirst() |
boolean |
removeFirstOccurrence(char elem) |
char |
removeLast() |
boolean |
removeLastOccurrence(char elem) |
void |
resize(int len,
char elem)
Resizes the list so it will afterwards have a size of
len. |
boolean |
retainAll(CharGapList coll) |
boolean |
retainAll(java.util.Collection<java.lang.Character> coll) |
void |
reverse()
Reverses the order of all elements in the specified list.
|
void |
reverse(int index,
int len)
Reverses the order of the specified elements in the list.
|
void |
rotate(int distance)
Rotate specified elements in the list.
|
void |
rotate(int index,
int len,
int distance)
Rotate specified elements in the list.
|
char |
set(int index,
char elem) |
void |
setAll(int index,
char... elems)
Replaces the specified elements.
|
void |
setAll(int index,
CharGapList list)
Replaces the specified elements.
|
void |
setAll(int index,
java.util.Collection<java.lang.Character> coll)
Replaces the specified elements.
|
int |
size() |
void |
sort()
Sort elements in the list using the specified comparator.
|
void |
sort(int index,
int len)
Sort specified elements in the list using the specified comparator.
|
static void |
swap(CharGapList src,
int srcIndex,
CharGapList dst,
int dstIndex,
int len)
Swaps elements from two GapLists.
|
void |
swap(int index1,
int index2,
int len)
Swap the specified elements in the list.
|
char[] |
toArray() |
char[] |
toArray(char[] array) |
char[] |
toArray(int index,
int len)
Returns an array containing the specified elements in this list.
|
java.lang.String |
toString() |
void |
trimToSize()
Trims the capacity of this CharGapList instance to be the
list's current size.
|
CharGapList |
unmodifiableList()
Returns an unmodifiable view of this list.
|
public CharGapList()
public CharGapList(int capacity)
capacity - capacity to usepublic CharGapList(java.util.Collection<java.lang.Character> that)
that - source object to copypublic CharGapList(char... that)
that - source object to copypublic static CharGapList EMPTY()
public static CharGapList create()
type - of elements stored in the listpublic static CharGapList create(int capacity)
capacity - capacitytype - of elements stored in the listpublic static CharGapList create(java.util.Collection<java.lang.Character> coll)
coll - collection with elementtype - of elements stored in the listpublic static CharGapList create(char... elems)
elems - array with elementstype - of elements stored in the listpublic void init()
public void init(int capacity)
capacity - capacitypublic void init(java.util.Collection<java.lang.Character> coll)
coll - collection with elementspublic void init(char... elems)
elems - array with elementspublic CharGapList copy()
clone()public CharGapList unmodifiableList()
public java.lang.Object clone()
clone in class java.lang.Objectpublic void clear()
public int size()
public int capacity()
public char get(int index)
public char set(int index,
char elem)
public boolean add(char elem)
public void add(int index,
char elem)
public char remove(int index)
public void ensureCapacity(int minCapacity)
minCapacity - the desired minimum capacitypublic void trimToSize()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean isEmpty()
public int indexOf(char elem)
public int lastIndexOf(char elem)
public boolean contains(char elem)
public boolean containsAny(java.util.Collection<java.lang.Character> coll)
coll - collection with elements to be containedpublic boolean containsAll(java.util.Collection<java.lang.Character> coll)
public boolean removeAll(java.util.Collection<java.lang.Character> coll)
public boolean removeAll(CharGapList coll)
removeAll(Collection)public boolean retainAll(java.util.Collection<java.lang.Character> coll)
public boolean retainAll(CharGapList coll)
retainAll(Collection)public char[] toArray()
public char[] toArray(int index,
int len)
index - index of first element to copylen - number of elements to copypublic char[] toArray(char[] array)
public boolean addAll(java.util.Collection<java.lang.Character> coll)
coll - collection containing elements to be added to this listjava.lang.NullPointerException - if the specified collection is (char)0public boolean addAll(int index,
java.util.Collection<java.lang.Character> coll)
index - index at which to insert the first element from the
specified collectioncoll - collection containing elements to be inserted into this listjava.lang.IndexOutOfBoundsException - if the index is invalidjava.lang.NullPointerException - if the specified collection is (char)0public boolean addAll(char... elems)
elems - elements to be added to this listpublic boolean addAll(int index,
char... elems)
index - index at which to insert the first element from the
specified collectionelems - elements to be inserted into this listjava.lang.IndexOutOfBoundsException - if the index is invalidpublic boolean addAll(CharGapList list)
list - collection containing elements to be added to this listjava.lang.NullPointerException - if the specified list is (char)0public boolean addAll(int index,
CharGapList list)
index - index at which to insert the first element from the
specified collectionlist - list containing elements to be inserted into this listjava.lang.IndexOutOfBoundsException - if the index is invalidjava.lang.NullPointerException - if the specified collection is (char)0public char getFirst()
public char getLast()
public void addFirst(char elem)
public void addLast(char elem)
public char removeFirst()
public char removeLast()
public char peek()
public char element()
public char poll()
public char remove()
public boolean offer(char elem)
public boolean offerFirst(char elem)
public boolean offerLast(char elem)
public char peekFirst()
public char peekLast()
public char pollFirst()
public char pollLast()
public char pop()
public void push(char elem)
public boolean removeFirstOccurrence(char elem)
public boolean removeLastOccurrence(char elem)
public static void move(CharGapList src, int srcIndex, CharGapList dst, int dstIndex, int len)
src - source listsrcIndex - index of first element in source listdst - destination listdstIndex - index of first element in source listlen - number of elements to movetype - of elements stored in the listjava.lang.IndexOutOfBoundsException - if the ranges are invalidpublic static void copy(CharGapList src, int srcIndex, CharGapList dst, int dstIndex, int len)
src - source listsrcIndex - index of first element in source listdst - destination listdstIndex - index of first element in source listlen - number of elements to copytype - of elements stored in the listjava.lang.IndexOutOfBoundsException - if the ranges are invalidpublic static void swap(CharGapList src, int srcIndex, CharGapList dst, int dstIndex, int len)
src - first listsrcIndex - index of first element in first listdst - second listdstIndex - index of first element in second listlen - number of elements to swaptype - of elements stored in the listjava.lang.IndexOutOfBoundsException - if the ranges are invalidpublic CharGapList getAll(int index, int len)
index - index of first element to retrievelen - number of elements to retrievepublic char[] getArray(int index,
int len)
index - index of first element to retrievelen - number of elements to retrievepublic void setAll(int index,
CharGapList list)
index - index of first element to setlist - list with elements to setpublic void setAll(int index,
java.util.Collection<java.lang.Character> coll)
index - index of first element to setcoll - collection with elements to setpublic void setAll(int index,
char... elems)
index - index of first element to setelems - elements to setpublic void remove(int index,
int len)
index - index of first element to removelen - number of elements to removepublic void init(int len,
char elem)
len and contain only the element elem.
The list will grow or shrink as needed.len - length of listelem - element which the list will containpublic void resize(int len,
char elem)
len. If the list must grow, the specified
element elem will be used for filling.len - length of listelem - element which will be used for extending the listpublic void fill(char elem)
elem - element used for fillingpublic void fill(int index,
int len,
char elem)
index - index of first element to filllen - number of elements to fillelem - element used for fillingpublic void copy(int srcIndex,
int dstIndex,
int len)
srcIndex - index of first source element to copydstIndex - index of first destination element to copylen - number of elements to copypublic void move(int srcIndex,
int dstIndex,
int len)
srcIndex - index of first source element to movedstIndex - index of first destination element to movelen - number of elements to movepublic void reverse()
public void reverse(int index,
int len)
index - index of first element to reverselen - number of elements to reversepublic void swap(int index1,
int index2,
int len)
index1 - index of first element in first range to swapindex2 - index of first element in second range to swaplen - number of elements to swapjava.lang.IndexOutOfBoundsException - if the ranges overlappublic void rotate(int distance)
distance - distance to move the elementspublic void rotate(int index,
int len,
int distance)
index - index of first element to rotatelen - number of elements to rotatedistance - distance to move the elementspublic void sort()
comparator - comparator to use for sorting
((char)0 means the elements natural ordering should be used)Arrays.sort(int[])public void sort(int index,
int len)
index - index of first element to sortlen - number of elements to sortcomparator - comparator to use for sorting
((char)0 means the elements natural ordering should be used)Arrays.sort(int[])public int binarySearch(char key)
key - the value to be searched forcomparator - the comparator by which the list is ordered.
A (char)0 value indicates that the elements'
natural ordering should be used.Arrays.binarySearch(long[], long)public int binarySearch(int index,
int len,
char key)
index - index of first element to searchlen - number of elements to searchkey - the value to be searched forcomparator - the comparator by which the list is ordered.
A (char)0 value indicates that the elements'
natural ordering should be used.Arrays.binarySearch(long[], long)