T
- the generic type of this
public class DoublyLinkedList<T> extends LinkedListSecondary<T>
[$this.preFront is not null] [$this.preFocus is not null] [$this.rear is not null] [$this.length >= 0] [$this.position < length] [$this.position = -1 if $this.length = 0] [$this.position = distance of this.focus from $this.preFront] [$this.preFocus points to the node just before the node containing the label that is in focus to the client if ($this.length > 0) and points to $this.preFront if $this.length = 0] [$this.preFront points to the leading sentinel node] [$this.postRear points to the trailing sentinel node] [$this.rear points to the node directly before $this.postRear] [$this.length = total number of nodes minus 2 for the sentinel nodes]
this = [label in nodes between, and not including, $this.preFront and $this.postRear] focus = [this.preFocus.next]
Constructor and Description |
---|
DoublyLinkedList()
No-arg constructor for
this . |
Modifier and Type | Method and Description |
---|---|
void |
add(T entry)
Appends
entry to the end of #this. |
void |
addToFront(T entry)
Adds
entry to the front of #this. |
void |
advance()
Shifts
#this.focus forward by 1 position. |
void |
clear()
Resets
this to its initial value. |
T |
focus()
Returns a reference to
#this.focus . |
int |
hashCode()
Note: Opted for a more efficient implementation.
|
void |
insert(T entry)
Inserts
entry into #this at the position directly
following the #this.focus . |
java.util.Iterator<T> |
iterator() |
int |
length()
Returns the number of entries in
this . |
void |
moveToFront()
Shifts
this.focus to the front of the list. |
void |
moveToRear()
Moves
#this.focus to the last entry in this . |
DoublyLinkedList<T> |
newInstance()
Returns a new object with the same dynamic type as
this , having
an initial value. |
int |
position()
Returns the position of
#this.focus . |
T |
remove()
Removes
this.focus and returns it to the caller. |
T |
removeRear()
Removes and returns the final entry in
this . |
void |
retreat()
Shifts
this.focus to the entry previous to #this.focus . |
void |
transferFrom(LinkedList<T> source)
Sets
this to the incoming value of source, and resets
source to an initial value; the declaration notwithstanding, the
dynamic type of source must be the same as the dynamic type of
this . |
contains, equals, moveToPosition, removeFront, toString
public void add(T entry)
LinkedListKernel
entry
to the end of #this.entry
- item to be appended to this
public void addToFront(T entry)
LinkedListKernel
entry
to the front of #this.entry
- item to be prepended to this
public T remove()
LinkedListKernel
this.focus
and returns it to the caller.
this.focus
will be shifted to the right, and if
#this.focus
was the last entry, then this.focus
shifts to
the first entry in #this
.#this.focus
public T removeRear()
LinkedList
this
.removeRear
in interface LinkedList<T>
removeRear
in class LinkedListSecondary<T>
this
public void advance()
LinkedListKernel
#this.focus
forward by 1 position.public void retreat()
LinkedListKernel
this.focus
to the entry previous to #this.focus
.public void moveToFront()
LinkedListKernel
this.focus
to the front of the list.public int length()
LinkedListKernel
this
.this
public void insert(T entry)
LinkedListKernel
entry
into #this
at the position directly
following the #this.focus
.entry
- entry to be inserted into the listpublic T focus()
LinkedListKernel
#this.focus
.#this.focus
public void moveToRear()
LinkedListKernel
#this.focus
to the last entry in this
.public int position()
LinkedListKernel
#this.focus
.this.focus
fron the front of the listpublic java.util.Iterator<T> iterator()
public void clear()
Standard
this
to its initial value.public void transferFrom(LinkedList<T> source)
Standard
this
to the incoming value of source, and resets
source
to an initial value; the declaration notwithstanding, the
dynamic type of source
must be the same as the dynamic type of
this
. If the type T has a no-argument constructor, then
source
satisfies the contract of the no-argument constructor for
T. If T does not have a no-argument constructor, then source satisfies
the contract of the constructor call that was used to initialize
#source
.source
- object whose value is to be transferredpublic DoublyLinkedList<T> newInstance()
Standard
this
, having
an initial value. If the type T has a no-argument constructor, then the
value of the new returned object satisfies the contract of the
no-argument constructor for T. If T does not have a no-argument
constructor, then the value of the new returned object satisfies the
contract of the constructor call that was used to initialize
this
.this
with an initial valuepublic int hashCode()
hashCode
in class LinkedListSecondary<T>