public class LongGapList
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Note that this implementation is not synchronized.
GapList,
LongObjGapList,
Serialized Form| Constructor and Description |
|---|
LongGapList()
Construct a list with the default initial capacity.
|
LongGapList(java.util.Collection<java.lang.Long> coll)
Construct a list to contain the specified elements.
|
LongGapList(int capacity)
Construct a list with specified initial capacity.
|
LongGapList(long... elems)
Construct a list to contain the specified elements.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
long elem) |
boolean |
add(long elem) |
boolean |
addAll(java.util.Collection<java.lang.Long> coll)
Adds all of the elements in the specified collection into this list.
|
boolean |
addAll(int index,
java.util.Collection<java.lang.Long> coll)
Inserts all of the elements in the specified collection into this
list, starting at the specified position.
|
boolean |
addAll(int index,
long... elems)
Inserts the specified elements into this list,
starting at the specified position.
|
boolean |
addAll(int index,
LongGapList list)
Inserts all of the elements in the specified list into this
list, starting at the specified position.
|
boolean |
addAll(long... elems)
Adds all specified elements into this list.
|
boolean |
addAll(LongGapList list)
Adds all of the elements in the specified list into this list.
|
void |
addFirst(long elem) |
void |
addLast(long elem) |
int |
binarySearch(int index,
int len,
long key)
Searches the specified range for an object using the binary
search algorithm.
|
int |
binarySearch(long key)
Searches the specified range for an object using the binary
search algorithm.
|
int |
capacity()
Returns capacity of this LongGapList.
|
void |
clear() |
java.lang.Object |
clone()
Returns a shallow copy of this LongGapList instance
(The elements themselves are not copied).
|
boolean |
contains(long elem) |
boolean |
containsAll(java.util.Collection<java.lang.Long> coll) |
boolean |
containsAny(java.util.Collection<java.lang.Long> coll)
Returns true if any of the elements of the specified collection is contained in the list.
|
LongGapList |
copy()
Returns a shallow copy of this LongGapList instance
(the new list will contain the same elements as the source list, i.e. the elements themselves are not copied).
|
void |
copy(int srcIndex,
int dstIndex,
int len)
Copy specified elements.
|
static void |
copy(LongGapList src,
int srcIndex,
LongGapList dst,
int dstIndex,
int len)
Copies elements from one LongGapList to another.
|
static LongGapList |
create()
Create new list.
|
static LongGapList |
create(java.util.Collection<java.lang.Long> coll)
Create new list with specified elements.
|
static LongGapList |
create(int capacity)
Create new list with specified capacity.
|
static LongGapList |
create(long... elems)
Create new list with specified elements.
|
long |
element() |
static LongGapList |
EMPTY() |
void |
ensureCapacity(int minCapacity)
Increases the capacity of this LongGapList 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(int index,
int len,
long elem)
Fill specified elements.
|
void |
fill(long elem)
Fill list.
|
long |
get(int index) |
LongGapList |
getAll(int index,
int len)
Returns specified range of elements from list.
|
long[] |
getArray(int index,
int len)
Returns specified range of elements from list.
|
long |
getFirst() |
long |
getLast() |
int |
hashCode() |
int |
indexOf(long elem) |
void |
init()
Initialize the list to be empty.
|
void |
init(java.util.Collection<java.lang.Long> coll)
Initialize the list to contain the specified elements only.
|
void |
init(int capacity)
Initialize the list to be empty with specified initial capacity.
|
void |
init(int len,
long elem)
Initializes the list so it will afterwards have a size of
len and contain only the element elem. |
void |
init(long... elems)
Initialize the list to contain the specified elements only.
|
boolean |
isEmpty() |
int |
lastIndexOf(long elem) |
void |
move(int srcIndex,
int dstIndex,
int len)
Move specified elements.
|
static void |
move(LongGapList src,
int srcIndex,
LongGapList dst,
int dstIndex,
int len)
Moves elements from one LongGapList to another.
|
boolean |
offer(long elem) |
boolean |
offerFirst(long elem) |
boolean |
offerLast(long elem) |
long |
peek() |
long |
peekFirst() |
long |
peekLast() |
long |
poll() |
long |
pollFirst() |
long |
pollLast() |
long |
pop() |
void |
push(long elem) |
long |
remove() |
long |
remove(int index) |
void |
remove(int index,
int len)
Remove specified range of elements from list.
|
boolean |
removeAll(java.util.Collection<java.lang.Long> coll) |
boolean |
removeAll(LongGapList coll) |
long |
removeFirst() |
boolean |
removeFirstOccurrence(long elem) |
long |
removeLast() |
boolean |
removeLastOccurrence(long elem) |
void |
resize(int len,
long elem)
Resizes the list so it will afterwards have a size of
len. |
boolean |
retainAll(java.util.Collection<java.lang.Long> coll) |
boolean |
retainAll(LongGapList 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.
|
long |
set(int index,
long elem) |
void |
setAll(int index,
java.util.Collection<java.lang.Long> coll)
Replaces the specified elements.
|
void |
setAll(int index,
long... elems)
Replaces the specified elements.
|
void |
setAll(int index,
LongGapList list)
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.
|
void |
swap(int index1,
int index2,
int len)
Swap the specified elements in the list.
|
static void |
swap(LongGapList src,
int srcIndex,
LongGapList dst,
int dstIndex,
int len)
Swaps elements from two GapLists.
|
long[] |
toArray() |
long[] |
toArray(int index,
int len)
Returns an array containing the specified elements in this list.
|
long[] |
toArray(long[] array) |
java.lang.String |
toString() |
void |
trimToSize()
Trims the capacity of this LongGapList instance to be the
list's current size.
|
LongGapList |
unmodifiableList()
Returns an unmodifiable view of this list.
|
public LongGapList()
public LongGapList(int capacity)
capacity - capacitypublic LongGapList(java.util.Collection<java.lang.Long> coll)
coll - collection with elementspublic LongGapList(long... elems)
elems - array with elementspublic static LongGapList EMPTY()
public static LongGapList create()
type - of elements stored in the listpublic static LongGapList create(int capacity)
capacity - capacitytype - of elements stored in the listpublic static LongGapList create(java.util.Collection<java.lang.Long> coll)
coll - collection with elementtype - of elements stored in the listpublic static LongGapList create(long... 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.Long> coll)
coll - collection with elementspublic void init(long... elems)
elems - array with elementspublic LongGapList copy()
clone()public LongGapList unmodifiableList()
public java.lang.Object clone()
clone in class java.lang.Objectpublic void clear()
public int size()
public int capacity()
public long get(int index)
public long set(int index,
long elem)
public boolean add(long elem)
public void add(int index,
long elem)
public long 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(long elem)
public int lastIndexOf(long elem)
public boolean contains(long elem)
public boolean containsAny(java.util.Collection<java.lang.Long> coll)
coll - collection with elements to be containedpublic boolean containsAll(java.util.Collection<java.lang.Long> coll)
public boolean removeAll(java.util.Collection<java.lang.Long> coll)
public boolean removeAll(LongGapList coll)
removeAll(Collection)public boolean retainAll(java.util.Collection<java.lang.Long> coll)
public boolean retainAll(LongGapList coll)
retainAll(Collection)public long[] toArray()
public long[] toArray(int index,
int len)
index - index of first element to copylen - number of elements to copypublic long[] toArray(long[] array)
public boolean addAll(java.util.Collection<java.lang.Long> coll)
coll - collection containing elements to be added to this listjava.lang.NullPointerException - if the specified collection is (long)0public boolean addAll(int index,
java.util.Collection<java.lang.Long> 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 (long)0public boolean addAll(long... elems)
elems - elements to be added to this listpublic boolean addAll(int index,
long... 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(LongGapList list)
list - collection containing elements to be added to this listjava.lang.NullPointerException - if the specified list is (long)0public boolean addAll(int index,
LongGapList 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 (long)0public long peek()
public long element()
public long poll()
public long remove()
public boolean offer(long elem)
public long getFirst()
public long getLast()
public void addFirst(long elem)
public void addLast(long elem)
public long removeFirst()
public long removeLast()
public boolean offerFirst(long elem)
public boolean offerLast(long elem)
public long peekFirst()
public long peekLast()
public long pollFirst()
public long pollLast()
public long pop()
public void push(long elem)
public boolean removeFirstOccurrence(long elem)
public boolean removeLastOccurrence(long elem)
public static void move(LongGapList src, int srcIndex, LongGapList 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(LongGapList src, int srcIndex, LongGapList 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(LongGapList src, int srcIndex, LongGapList 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 LongGapList getAll(int index, int len)
index - index of first element to retrievelen - number of elements to retrievepublic long[] getArray(int index,
int len)
index - index of first element to retrievelen - number of elements to retrievepublic void setAll(int index,
LongGapList list)
index - index of first element to setlist - list with elements to setpublic void setAll(int index,
java.util.Collection<java.lang.Long> coll)
index - index of first element to setcoll - collection with elements to setpublic void setAll(int index,
long... 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,
long 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,
long 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(long elem)
elem - element used for fillingpublic void fill(int index,
int len,
long 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
((long)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
((long)0 means the elements natural ordering should be used)Arrays.sort(int[])public int binarySearch(long key)
key - the value to be searched forcomparator - the comparator by which the list is ordered.
A (long)0 value indicates that the elements'
natural ordering should be used.Arrays.binarySearch(long[], long)public int binarySearch(int index,
int len,
long 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 (long)0 value indicates that the elements'
natural ordering should be used.Arrays.binarySearch(long[], long)