|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractList<T> org.eclipse.jgit.util.BlockList<T>
T
- type of list element.public class BlockList<T>
Random access list that allocates entries in blocks.
Unlike ArrayList
, this type does not need to reallocate the
internal array in order to expand the capacity of the list. Access to any
element is constant time, but requires two array lookups instead of one.
To handle common usages, add(Object)
and iterator()
use
internal code paths to amortize out the second array lookup, making addition
and simple iteration closer to one array operation per element processed.
Similar to ArrayList
, adding or removing from any position except the
end of the list requires O(N) time to copy all elements between the
modification point and the end of the list. Applications are strongly
encouraged to not use this access pattern with this list implementation.
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
BlockList()
Initialize an empty list. |
|
BlockList(int capacity)
Initialize an empty list with an expected capacity. |
Method Summary | |
---|---|
void |
add(int index,
T element)
|
boolean |
add(T element)
|
void |
addAll(BlockList<T> src)
Quickly append all elements of another BlockList. |
void |
addAll(T[] src,
int srcIdx,
int srcCnt)
Quickly append all elements from an array. |
void |
clear()
|
T |
get(int index)
|
Iterator<T> |
iterator()
|
T |
remove(int index)
|
T |
set(int index,
T element)
|
int |
size()
|
Methods inherited from class java.util.AbstractList |
---|
addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
Constructor Detail |
---|
public BlockList()
public BlockList(int capacity)
capacity
- number of elements expected to be in the list.Method Detail |
---|
public int size()
size
in interface Collection<T>
size
in interface List<T>
size
in class AbstractCollection<T>
public void clear()
clear
in interface Collection<T>
clear
in interface List<T>
clear
in class AbstractList<T>
public T get(int index)
get
in interface List<T>
get
in class AbstractList<T>
public T set(int index, T element)
set
in interface List<T>
set
in class AbstractList<T>
public void addAll(BlockList<T> src)
src
- the list to copy elements from.public void addAll(T[] src, int srcIdx, int srcCnt)
src
- the source array.srcIdx
- first index to copy.srcCnt
- number of elements to copy.public boolean add(T element)
add
in interface Collection<T>
add
in interface List<T>
add
in class AbstractList<T>
public void add(int index, T element)
add
in interface List<T>
add
in class AbstractList<T>
public T remove(int index)
remove
in interface List<T>
remove
in class AbstractList<T>
public Iterator<T> iterator()
iterator
in interface Iterable<T>
iterator
in interface Collection<T>
iterator
in interface List<T>
iterator
in class AbstractList<T>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |