E - the element typepublic class ChunkedArrayList<E> extends AbstractList<E> implements RandomAccess
List implementation optimised for the following case:
clear()), particularly from the middle or start
of the listArrayList
pre-allocated to a specified chunk size. This has the advantage over a single
ArrayList that growth in the list does not cause constant re-allocation of arrays of
increasing size, with the consequent copying of the previous entries.| Modifier and Type | Field and Description |
|---|---|
static int |
defaultChunkSize |
static int |
defaultInitialChunks |
static int |
minimumChunkSize |
modCount| Constructor and Description |
|---|
ChunkedArrayList()
Construct a
ChunkedArrayList with the default chunk size and initial number of
chunks. |
ChunkedArrayList(Collection<? extends E> c)
Construct a
ChunkedArrayList with the default chunk size and initial number of
chunks, and then populate the list from an existing Collection. |
ChunkedArrayList(int chunkSize)
Construct a
ChunkedArrayList with the specified chunk size and the default
initial number of chunks. |
ChunkedArrayList(int chunkSize,
int initialChunks)
Construct a
ChunkedArrayList with the specified chunk size and initial number of
chunks. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e)
Appends the specified element to the end of this list.
|
void |
add(int index,
E element)
Inserts the supplied element at the specified position in this list.
|
void |
clear()
Removes all of the elements from this list.
|
boolean |
contains(Object o) |
E |
get(int index) |
int |
indexOf(Object o)
Returns the index of the first occurrence of the specified element in this list, or -1
if this list does not contain the element.
|
int |
lastIndexOf(Object o)
Returns the index of the last occurrence of the specified element in this list, or -1 if
this list does not contain the element.
|
E |
remove(int index)
Removes the element at the specified position in this list.
|
boolean |
remove(Object o) |
E |
set(int index,
E element)
Replaces the element at the specified position in this list with the specified element.
|
int |
size() |
addAll, equals, hashCode, iterator, listIterator, listIterator, removeRange, subListaddAll, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddAll, containsAll, isEmpty, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArrayparallelStream, removeIf, streampublic static final int defaultChunkSize
public static final int defaultInitialChunks
public static final int minimumChunkSize
public ChunkedArrayList(int chunkSize,
int initialChunks)
ChunkedArrayList with the specified chunk size and initial number of
chunks.chunkSize - the chunk sizeinitialChunks - the initial number of chunksIllegalArgumentException - if the chunk size is less than the minimumpublic ChunkedArrayList(int chunkSize)
ChunkedArrayList with the specified chunk size and the default
initial number of chunks.chunkSize - the chunk sizeIllegalArgumentException - if the chunk size is less than the minimumpublic ChunkedArrayList()
ChunkedArrayList with the default chunk size and initial number of
chunks.public ChunkedArrayList(Collection<? extends E> c)
ChunkedArrayList with the default chunk size and initial number of
chunks, and then populate the list from an existing Collection.c - the Collection to be copied to this listpublic int size()
size in interface Collection<E>size in interface List<E>size in class AbstractCollection<E>public boolean contains(Object o)
contains in interface Collection<E>contains in interface List<E>contains in class AbstractCollection<E>public boolean add(E e)
add in interface Collection<E>add in interface List<E>add in class AbstractList<E>e - public boolean remove(Object o)
remove in interface Collection<E>remove in interface List<E>remove in class AbstractCollection<E>public void clear()
clear in interface Collection<E>clear in interface List<E>clear in class AbstractList<E>public E get(int index)
public E set(int index, E element)
set in interface List<E>set in class AbstractList<E>ClassCastExceptionIndexOutOfBoundsExceptionpublic void add(int index,
E element)
add in interface List<E>add in class AbstractList<E>ClassCastExceptionIndexOutOfBoundsExceptionpublic E remove(int index)
remove in interface List<E>remove in class AbstractList<E>IndexOutOfBoundsExceptionpublic int indexOf(Object o)
public int lastIndexOf(Object o)
lastIndexOf in interface List<E>lastIndexOf in class AbstractList<E>o - Copyright © 2020. All rights reserved.