E - type of elements stored in the listpublic class GapList<E> extends IList<E>
Note that this implementation is not synchronized.
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(E... elems)
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)
Appends the specified element to the end of this list (optional
operation).
|
void |
add(int index,
E elem)
Inserts the specified element at the specified position in this list
(optional operation).
|
<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 GapList.
|
GapList<E> |
copy()
Returns a shallow copy of this GapList instance
(the new list will contain the same elements as the source list, i.e. the elements themselves are not copied).
|
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.
|
static <E> GapList<E> |
create(int capacity)
Create new list with specified capacity.
|
IList<E> |
doCreate(int capacity)
Create list with specified capacity.
|
static <EE> GapList<EE> |
EMPTY() |
E |
get(int index)
Returns the element at the specified position in this list.
|
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.
|
void |
init(int capacity)
Initialize the list to be empty with specified initial capacity.
|
<R> GapList<R> |
mappedList(Mapper<E,R> mapper)
Create a new list by applying the specified mapper to all elements.
|
E |
remove(int index)
Removes the element at the specified position in this list (optional
operation).
|
int |
size()
Returns the number of elements in this collection.
|
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, addAll, addAll, addFirst, addIfAbsent, addLast, binarySearch, clear, clone, contains, containsAll, containsAny, copy, copy, descendingIterator, drag, element, ensureCapacity, equals, fill, fill, filter, getArray, getCount, getDistinct, getFirst, getLast, hashCode, indexOf, init, isEmpty, iterator, lastIndexOf, listIterator, listIterator, move, move, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, remove, removeAll, removeAll, removeAll, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, resize, retainAll, retainAll, reverse, reverse, rotate, rotate, set, setAll, setAll, setAll, sort, swap, swap, toArray, toArray, toArray, toStringpublic static final int DEFAULT_CAPACITY
public GapList()
public GapList(int capacity)
capacity - capacitypublic GapList(java.util.Collection<? extends E> coll)
coll - collection with elementspublic GapList(E... elems)
elems - array 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(int capacity)
E - type of elements stored in the listcapacity - capacitypublic 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(int capacity)
capacity - capacitypublic 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()
IListcopy in class IList<E>IList.clone()public GapList<E> unmodifiableList()
IListunmodifiableList in class IList<E>public int size()
java.util.Collectionpublic int capacity()
IListpublic E get(int index)
java.util.AbstractListpublic boolean add(E elem)
java.util.AbstractListLists that support this operation may place limitations on what elements may be added to this list. In particular, some lists will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. List classes should clearly specify in their documentation any restrictions on what elements may be added.
This implementation calls add(size(), e).
Note that this implementation throws an
UnsupportedOperationException unless
add(int, E) is overridden.
add in interface java.util.Collection<E>add in interface java.util.Deque<E>add in interface java.util.List<E>add in interface java.util.Queue<E>add in class IList<E>elem - element to be appended to this listtrue (as specified by Collection.add(E))public void add(int index,
E elem)
java.util.AbstractListThis implementation always throws an
UnsupportedOperationException.
public GapList<E> getAll(int index, int len)
IListpublic GapList<E> getAll(E elem)
IListpublic <R> GapList<R> mappedList(Mapper<E,R> mapper)
IListmappedList in class IList<E>mapper - mapper functionpublic E remove(int index)
java.util.AbstractListThis implementation always throws an
UnsupportedOperationException.
public void trimToSize()
IListtrimToSize 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)