public abstract class AbstractLinkedList<T,N extends AbstractLinkedList.Node<T,N>,L extends AbstractLinkedList<T,N,L>> extends Object implements Iterable<T>
SimpleStack), but it leaves room to be extended
into a doubly-linked list (SimpleLinkedList).| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractLinkedList.Node<T,N extends AbstractLinkedList.Node<T,N>> |
protected class |
AbstractLinkedList.NodeIterator |
| Constructor and Description |
|---|
AbstractLinkedList() |
| Modifier and Type | Method and Description |
|---|---|
L |
add(T item) |
void |
clear() |
L |
consume(L other)
Forcibly takes all elements from one stack and attaches them to this.
|
T |
head() |
boolean |
isEmpty() |
Iterator<T> |
iterator() |
String |
join(String separator)
toStrings the items in the stack with the specified separator
|
protected abstract N |
newNode(T item)
Called whenever a node is created, including the
head node. |
protected void |
onAdd(N previous,
N next) |
T |
tail() |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic void clear()
public L consume(L other)
This method destroys the stack you send to it.
Note that it is threadsafe with respect to the stack consuming, but not so with the stack being consumed (deadlock's no fun).
Since you are destroying it anyway, chances are the stack is getting gc'd as soon as it pops off the, well... [execution] stack!
This method is destructive because you _really_ don't want to allow cyclic references when two stacks reference each other.
public T head()
public boolean isEmpty()
public String join(String separator)
public T tail()
protected abstract N newNode(T item)
head node.item - -> The item that will become the value for this node. Expect a
null for the head node.Copyright © December 07, 2012–2015 The Internet Party. All rights reserved.