public class BigList<E> extends IList<E>
Note that this implementation is not synchronized. Due to data caching used for exploiting locality of reference, performance can decrease if BigList is accessed by several threads at different positions.
Note that the iterators provided are not fail-fast.
Modifier and Type | Class and Description |
---|---|
protected static class |
BigList.ReadOnlyBigList<E>
A read-only version of
Key1List . |
IList.IListableFromArray<E>, IList.IListableFromCollection<E>, IList.IListableFromList<E>, IList.IListableFromMult<E>
Modifier | Constructor and Description |
---|---|
|
BigList()
Default constructor.
|
protected |
BigList(boolean copy,
BigList<E> that)
Constructor used internally, e.g. for ImmutableBigList.
|
|
BigList(java.util.Collection<? extends E> coll)
Create new list with specified elements.
|
|
BigList(int blockSize)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
<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 |
blockSize()
Returns block size used for this BigList.
|
int |
capacity()
As BigList grows and shrinks automatically, the term capacity does not really make sense.
|
BigList<E> |
clone()
Returns a shallow copy of this list.
|
BigList<E> |
copy()
Returns a shallow copy of this list.
|
static <E> BigList<E> |
create()
Create new list.
|
static <E> BigList<E> |
create(java.util.Collection<? extends E> coll)
Create new list with specified elements.
|
static <E> BigList<E> |
create(E... elems)
Create new list with specified elements.
|
BigList<E> |
crop()
Returns a copy this list but without elements.
|
protected boolean |
doAdd(int index,
E element)
Helper method for adding an element to the list.
|
protected boolean |
doAddAll(int index,
IListable<? extends E> list)
Helper method for adding multiple elements to the list.
|
protected void |
doAssign(IList<E> that)
Assign this list the content of the that list.
|
protected void |
doClear() |
protected void |
doClone(IList<E> that)
Initialize this object after the bitwise copy has been made by Object.clone().
|
protected IList<E> |
doCreate(int capacity)
Create list with specified capacity.
|
protected void |
doEnsureCapacity(int minCapacity)
Increases the capacity of this list instance, if
necessary, to ensure that it can hold at least the number of elements
specified by the minimum capacity argument.
|
protected E |
doGet(int index)
Helper method for getting an element from the list.
|
protected E |
doRemove(int index)
Helper method to remove an element.
|
protected void |
doRemoveAll(int index,
int len)
Remove specified range of elements from list.
|
protected E |
doReSet(int index,
E elem)
Sets an element at specified position.
|
protected E |
doSet(int index,
E elem)
Helper method for setting an element in the list.
|
static <EE> BigList<EE> |
EMPTY() |
protected void |
finalize() |
E |
getDefaultElem() |
BigList<E> |
immutableList()
Returns an immutable copy of this list.
|
boolean |
isReadOnly()
Returns true if this list is either unmodifiable or immutable, false otherwise.
|
int |
size()
Return size of list
|
void |
sort(int index,
int len,
java.util.Comparator<? super E> comparator)
Sort specified elements in the list using the specified comparator.
|
java.util.Spliterator<E> |
spliterator() |
void |
trimToSize()
Pack as many elements in the blocks as allowed.
|
BigList<E> |
unmodifiableList()
Returns an unmodifiable view of this list.
|
add, add, addAll, addAll, addAll, addAll, addArray, addArray, addArray, addArray, addFirst, addIfAbsent, addLast, addMult, addMult, asDeque, asIListable, binarySearch, checkIndex, checkIndexAdd, checkLength, checkLengths, checkNonNull, checkRange, clear, contains, containsAll, containsAny, containsIf, copy, count, countIf, descendingIterator, doCreateArray, doGetAll, doIndexOf, doIndexOfIf, doInitAll, doLastIndexOf, doLastIndexOfIf, doModify, doPutAll, doReplace, doRotate, drag, element, ensureCapacity, equals, extract, extractIf, fill, filter, filterMap, flatMap, get, getAll, getAll, getDistinct, getFirst, getFirstOrNull, getIf, getLast, getLastOrNull, getSingle, getSingleOrNull, hashCode, indexOf, indexOf, indexOfIf, indexOfIf, initAll, initAll, initArray, initMult, isEmpty, iterator, lastIndexOf, lastIndexOf, lastIndexOfIf, lastIndexOfIf, listIterator, listIterator, map, mapFilter, move, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, put, putAll, putAll, putArray, putMult, remove, remove, remove, remove, removeAll, removeAll, removeAll, removeFirst, removeFirstOccurrence, removeIf, removeLast, removeLastOccurrence, replace, replaceAll, replaceAll, replaceArray, replaceMult, resize, retain, retainAll, retainAll, retainIf, reverse, reverse, rotate, rotate, set, setAll, setAll, setArray, setArray, setMult, sort, swap, toArray, toArray, toArray, toArray, toArray, toArray, toString, transferCopy, transferMove, transferRemove, transferSwap, transform, transformedList
protected BigList(boolean copy, BigList<E> that)
copy
- true to copy all instance values from source,
if false nothing is donethat
- list to copypublic BigList()
public BigList(int blockSize)
blockSize
- block sizepublic BigList(java.util.Collection<? extends E> coll)
coll
- collection with elementpublic static <EE> BigList<EE> EMPTY()
public static <E> BigList<E> create()
E
- type of elements stored in the listpublic static <E> BigList<E> create(java.util.Collection<? extends E> coll)
E
- type of elements stored in the listcoll
- collection with elementpublic static <E> BigList<E> create(E... elems)
E
- type of elements stored in the listelems
- array with elementspublic int blockSize()
public BigList<E> crop()
IList
public boolean isReadOnly()
IList
isReadOnly
in class IList<E>
public BigList<E> copy()
The copy is realized by a copy-on-write approach so also really large lists can efficiently be handled.
public BigList<E> clone()
IList.copy()
to .
The copy is realized by a copy-on-write approach so also really large lists can efficiently be handled.
protected void doAssign(IList<E> that)
IList
protected void doClone(IList<E> that)
IList
public E getDefaultElem()
getDefaultElem
in class IList<E>
protected void finalize()
finalize
in class java.lang.Object
public java.util.Spliterator<E> spliterator()
public int size()
IListable
public int capacity()
protected E doGet(int index)
IList
protected E doSet(int index, E elem)
IList
protected E doReSet(int index, E elem)
IList
protected boolean doAdd(int index, E element)
IList
protected boolean doAddAll(int index, IListable<? extends E> list)
IList
protected void doRemoveAll(int index, int len)
IList
doRemoveAll
in class IList<E>
index
- index of first element to removelen
- number of elements to removeprotected E doRemove(int index)
IList
public BigList<E> unmodifiableList()
IList
IList.immutableList()
to get an immutable copy of a list.unmodifiableList
in class IList<E>
public BigList<E> immutableList()
IList
IList.unmodifiableList()
to get unmodifiable view of a list.immutableList
in class IList<E>
protected void doEnsureCapacity(int minCapacity)
IList
doEnsureCapacity
in class IList<E>
minCapacity
- the desired minimum capacitypublic void trimToSize()
trimToSize
in class IList<E>
protected IList<E> doCreate(int capacity)
IList
public void sort(int index, int len, java.util.Comparator<? super E> comparator)
IList
public <K> int binarySearch(int index, int len, K key, java.util.Comparator<? super K> comparator)
IList
Note that the method is defined to work with an arbitrary type <K>. This allows to search directly for a key field in the object without the need to construct an object containing the key:
persons.binarySearch("john", new SearchByName());
class SearchByName implements Comparator<Object> {
public int compare(Object o1, Object o2) {
String s1 = (o1 instanceof String) ? (String) o1 : ((Name) o1).getName();
String s2 = (o2 instanceof String) ? (String) o2 : ((Name) o2).getName();
return s1.compareTo(s2);
}
}
/
binarySearch
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)