public class LongLinkedList
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
LongLinkedList.Entry
Defines a list entry.
|
| Modifier and Type | Field and Description |
|---|---|
private static ArrayList<LongLinkedList.Entry> |
entryPool
Stores the
LongLinkedList.Entry pool. |
private LongLinkedList.Entry |
header
Defines the dummy header element where to hook into further list
elements.
|
private int |
size
Stores the size of the list.
|
| Constructor and Description |
|---|
LongLinkedList()
Constructs an empty list.
|
| Modifier and Type | Method and Description |
|---|---|
private LongLinkedList.Entry |
addBefore(long value,
LongLinkedList.Entry entry)
Adds a new entry before
entry. |
void |
addFirst(long value)
Inserts the specified element at the beginning of this list.
|
void |
addLast(long value)
Appends the specified element to the end of this list.
|
void |
clear()
Removes all of the elements from this list.
|
private static LongLinkedList.Entry |
getEntryFromPool(long value,
LongLinkedList.Entry next,
LongLinkedList.Entry previous)
Returns an entry from the shared pool.
|
private static void |
releaseEntry(LongLinkedList.Entry entry)
Releases and clears the specified
LongLinkedList.Entry
to the shared pool. |
private long |
remove(LongLinkedList.Entry entry)
Removes the given entry.
|
long |
removeFirst()
Removes and returns the first element from this list.
|
long |
removeLast()
Removes and returns the last element from this list.
|
int |
size()
Returns the number of elements in this list.
|
private static ArrayList<LongLinkedList.Entry> entryPool
LongLinkedList.Entry pool.private LongLinkedList.Entry header
private int size
private static final LongLinkedList.Entry getEntryFromPool(long value, LongLinkedList.Entry next, LongLinkedList.Entry previous)
value - the value of the returned entrynext - the next entry of the returned entryprevious - the previous entry of the returned entryprivate static final void releaseEntry(LongLinkedList.Entry entry)
LongLinkedList.Entry
to the shared pool.entry - the LongLinkedList.Entry to be released (must not
be null)private long remove(LongLinkedList.Entry entry)
entry - the entry to be removedjava.util.NoSuchElementException - if the entry cannot be removedpublic long removeFirst()
java.util.NoSuchElementException - if this list is emptypublic long removeLast()
java.util.NoSuchElementException - if this list is emptypublic void addFirst(long value)
value - the element to addpublic void addLast(long value)
value - the element to addprivate LongLinkedList.Entry addBefore(long value, LongLinkedList.Entry entry)
entry.value - the entry valueentry - the entry to insert into beforepublic void clear()
public int size()