|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.datastructures.NodePositionList<E>
public class NodePositionList<E>
Realization of a PositionList using a doubly-linked list of nodes.
Constructor Summary | |
---|---|
NodePositionList()
Constructor that creates an empty list; O(1) time |
Method Summary | ||
---|---|---|
void |
addAfter(Position<E> p,
E element)
Insert the given element after the given position; O(1) time |
|
void |
addBefore(Position<E> p,
E element)
Insert the given element before the given position; O(1) time |
|
void |
addFirst(E element)
Insert the given element at the beginning of the list, returning the new position; O(1) time |
|
void |
addLast(E element)
Insert the given element at the end of the list, returning the new position; O(1) time |
|
Position<E> |
first()
Returns the first position in the list; O(1) time |
|
static
|
forEachToString(PositionList<E> L)
Returns a textual representation of a given node list using for-each |
|
boolean |
isEmpty()
Returns whether the list is empty; O(1) time |
|
boolean |
isFirst(Position<E> p)
Returns whether a position is the first one; O(1) time |
|
boolean |
isLast(Position<E> p)
Returns whether a position is the last one; O(1) time |
|
java.util.Iterator<E> |
iterator()
Returns an iterator of all the elements in the list. |
|
Position<E> |
last()
Returns the last position in the list; O(1) time |
|
Position<E> |
next(Position<E> p)
Returns the position after the given one; O(1) time |
|
java.lang.Iterable<Position<E>> |
positions()
Returns an iterable collection of all the nodes in the list. |
|
Position<E> |
prev(Position<E> p)
Returns the position before the given one; O(1) time |
|
E |
remove(Position<E> p)
Remove the given position from the list; O(1) time |
|
E |
set(Position<E> p,
E element)
Replace the element at the given position with the new element and return the old element; O(1) time |
|
int |
size()
Returns the number of elements in the list; O(1) time |
|
void |
swapElements(Position<E> a,
Position<E> b)
Swap the elements of two give positions; O(1) time |
|
java.lang.String |
toString()
Returns a textual representation of the list |
|
static
|
toString(PositionList<E> l)
Returns a textual representation of a given node list |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NodePositionList()
Method Detail |
---|
public int size()
size
in interface PositionList<E>
public boolean isEmpty()
isEmpty
in interface PositionList<E>
public Position<E> first() throws EmptyListException
first
in interface PositionList<E>
EmptyListException
public Position<E> last() throws EmptyListException
last
in interface PositionList<E>
EmptyListException
public Position<E> prev(Position<E> p) throws InvalidPositionException, BoundaryViolationException
prev
in interface PositionList<E>
InvalidPositionException
BoundaryViolationException
public Position<E> next(Position<E> p) throws InvalidPositionException, BoundaryViolationException
next
in interface PositionList<E>
InvalidPositionException
BoundaryViolationException
public void addBefore(Position<E> p, E element) throws InvalidPositionException
addBefore
in interface PositionList<E>
InvalidPositionException
public void addAfter(Position<E> p, E element) throws InvalidPositionException
addAfter
in interface PositionList<E>
InvalidPositionException
public void addFirst(E element)
addFirst
in interface PositionList<E>
public void addLast(E element)
addLast
in interface PositionList<E>
public E remove(Position<E> p) throws InvalidPositionException
remove
in interface PositionList<E>
InvalidPositionException
public E set(Position<E> p, E element) throws InvalidPositionException
set
in interface PositionList<E>
InvalidPositionException
public java.util.Iterator<E> iterator()
iterator
in interface java.lang.Iterable<E>
iterator
in interface PositionList<E>
public java.lang.Iterable<Position<E>> positions()
positions
in interface PositionList<E>
public boolean isFirst(Position<E> p) throws InvalidPositionException
InvalidPositionException
public boolean isLast(Position<E> p) throws InvalidPositionException
InvalidPositionException
public void swapElements(Position<E> a, Position<E> b) throws InvalidPositionException
InvalidPositionException
public static <E> java.lang.String forEachToString(PositionList<E> L)
public static <E> java.lang.String toString(PositionList<E> l)
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |