static class VirtualFlow.ArrayLinkedList<T>
extends java.util.AbstractList<T>
This linked list like implementation is done using an array. It begins by putting the first item in the center of the allocated array, and then grows outward (either towards the first or last of the array depending on whether we are inserting at the head or tail). It maintains an index to the start and end of the array, so that it can efficiently expose iteration.
This class is package private solely for the sake of testing.
Modifier and Type | Field and Description |
---|---|
private java.util.ArrayList<T> |
array
The array list backing this class.
|
private int |
firstIndex |
private int |
lastIndex |
Constructor and Description |
---|
ArrayLinkedList() |
Modifier and Type | Method and Description |
---|---|
void |
addFirst(T cell) |
void |
addLast(T cell) |
void |
clear() |
T |
get(int index) |
T |
getFirst() |
T |
getLast() |
boolean |
isEmpty() |
T |
remove(int index) |
T |
removeFirst() |
T |
removeLast() |
int |
size() |
add, add, addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, set, subList
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
private final java.util.ArrayList<T> array
private int firstIndex
private int lastIndex
public T getFirst()
public T getLast()
public void addFirst(T cell)
public void addLast(T cell)
public int size()
public boolean isEmpty()
public T get(int index)
public void clear()
public T removeFirst()
public T removeLast()