E - type of elements stored in the listpublic class GapList<E> extends IList<E>
Note that this implementation is not synchronized.
Note that the iterators provided are not fail-fast.
List,
ArrayList,
LinkedList,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_CAPACITY
Default capacity for list
|
| Constructor and Description |
|---|
GapList()
Construct a list with the default initial capacity.
|
GapList(java.util.Collection<? extends E> coll)
Construct a list to contain the specified elements.
|
GapList(int capacity)
Construct a list with specified initial capacity.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E elem) |
void |
add(int index,
E elem) |
<K> int |
binarySearch(int index,
int len,
K key,
java.util.Comparator<? super K> comparator)
Searches the specified range for an object using the binary
search algorithm.
|
int |
capacity()
Returns capacity of this list.
|
java.lang.Object |
clone()
Returns a shallow copy of this GapList instance
(The elements themselves are not copied).
|
GapList<E> |
copy()
Returns a shallow copy of this GapList instance.
|
static <E> GapList<E> |
create()
Create new list.
|
static <E> GapList<E> |
create(java.util.Collection<? extends E> coll)
Create new list with specified elements.
|
static <E> GapList<E> |
create(E... elems)
Create new list with specified elements.
|
IList<E> |
doCreate(int capacity)
Create list with specified capacity.
|
static <EE> GapList<EE> |
EMPTY() |
void |
ensureCapacity(int minCapacity)
Increases the capacity of this GapList instance, if
necessary, to ensure that it can hold at least the number of elements
specified by the minimum capacity argument.
|
E |
get(int index) |
GapList<E> |
getAll(E elem)
Returns all elements in the list equal to the specified element.
|
GapList<E> |
getAll(int index,
int len)
Returns specified range of elements from list.
|
E |
getDefaultElem() |
void |
init()
Initialize the list to be empty.
|
void |
init(java.util.Collection<? extends E> coll)
Initialize the list to contain the specified elements only.
|
void |
init(E... elems)
Initialize the list to contain the specified elements only.
|
<R> GapList<R> |
mappedList(IFunction<E,R> mapper)
Create a new list by applying the specified mapper to all elements.
|
E |
remove(int index) |
int |
size() |
void |
sort(int index,
int len,
java.util.Comparator<? super E> comparator)
Sort specified elements in the list using the specified comparator.
|
void |
trimToSize()
Trims the capacity of this GapList instance to be the list's current size.
|
GapList<E> |
unmodifiableList()
Returns an unmodifiable view of this list.
|
addAll, addAll, addAll, addAll, addArray, addArray, addFirst, addIfAbsent, addLast, addMult, addMult, binarySearch, clear, contains, containsAll, containsAny, copy, descendingIterator, drag, element, equals, extract, extractWhere, fill, filter, getArray, getCount, getDistinct, getFirst, getLast, getWhere, hashCode, indexOf, indexOf, initAll, initAll, initArray, initMult, isEmpty, iterator, lastIndexOf, lastIndexOf, listIterator, listIterator, move, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, put, putAll, putAll, putArray, putMult, remove, remove, remove, removeAll, removeAll, removeAll, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, removeWhere, replaceAll, replaceAll, replaceArray, replaceMult, resize, retainAll, retainAll, retainWhere, reverse, reverse, rotate, rotate, set, setAll, setAll, setArray, setMult, sort, swap, toArray, toArray, toArray, toString, transferCopy, transferMove, transferRemove, transferSwappublic static final int DEFAULT_CAPACITY
public GapList()
public GapList(int capacity)
capacity - capacitypublic GapList(java.util.Collection<? extends E> coll)
coll - collection with elementspublic static <EE> GapList<EE> EMPTY()
public static <E> GapList<E> create()
E - type of elements stored in the listpublic static <E> GapList<E> create(java.util.Collection<? extends E> coll)
E - type of elements stored in the listcoll - collection with elementpublic static <E> GapList<E> create(E... elems)
E - type of elements stored in the listelems - array with elementspublic void init()
public void init(java.util.Collection<? extends E> coll)
coll - collection with elementspublic void init(E... elems)
elems - array with elementspublic E getDefaultElem()
public GapList<E> copy()
copy in class IList<E>IList.clone()public void ensureCapacity(int minCapacity)
ensureCapacity in class IList<E>minCapacity - the desired minimum capacitypublic java.lang.Object clone()
public GapList<E> unmodifiableList()
IListunmodifiableList in class IList<E>public int size()
public int capacity()
IListpublic E get(int index)
public boolean add(E elem)
public void add(int index,
E elem)
public GapList<E> getAll(int index, int len)
IListpublic GapList<E> getAll(E elem)
IListpublic <R> GapList<R> mappedList(IFunction<E,R> mapper)
IListmappedList in class IList<E>mapper - mapper functionpublic E remove(int index)
public void trimToSize()
trimToSize in class IList<E>public IList<E> doCreate(int capacity)
IListcapacity - initial capacity (use -1 for default capacity)public void sort(int index,
int len,
java.util.Comparator<? super E> comparator)
IListpublic <K> int binarySearch(int index,
int len,
K key,
java.util.Comparator<? super K> comparator)
IListbinarySearch in class IList<E>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 null value indicates that the elements'
natural ordering should be used.Arrays.binarySearch(long[], long)