Package dsa.lab02.solutions
Class SinglyLinkedList.Node<Item>
java.lang.Object
dsa.lab02.solutions.SinglyLinkedList.Node<Item>
- Type Parameters:
- Item- the item type
- All Implemented Interfaces:
- LinkedNode<Item>
- Enclosing class:
- SinglyLinkedList<Item>
A node in a singly-linked list.
 
Only holds a direct link to the next node.
- 
Constructor SummaryConstructorsConstructorDescriptionNode(SinglyLinkedList<Item> list, Item item) Construct a node with the given item.Node(SinglyLinkedList<Item> list, Item item, SinglyLinkedList.Node<Item> next) Construct a node with the given item and successor.
- 
Method SummaryModifier and TypeMethodDescriptionvoidinsertNext(Item item) Insert a node containing the given item immediately after this one in the list.voidinsertPrevious(Item item) Insert a node containing the given item immediately before this one in the list.item()Get the contained item.list()Get the containing list.next()Get the next node.previous()Get the previous node.remove()Remove the node from the list and return its item.Remove the next node from the list and return its item.Remove the previous node from the list and return its item.voidSet the contained item.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dsa.lab02.base.LinkedNodehasNext, hasPrevious, isFirst, isLast
- 
Constructor Details- 
NodeConstruct a node with the given item.- Parameters:
- list- the containing linked list
- item- the contained item
 
- 
NodeConstruct a node with the given item and successor.- Parameters:
- list- the containing linked list
- item- the contained item
- next- the next node
 
 
- 
- 
Method Details- 
listDescription copied from interface:LinkedNodeGet the containing list.- Specified by:
- listin interface- LinkedNode<Item>
- Returns:
- the list
 
- 
itemDescription copied from interface:LinkedNodeGet the contained item.- Specified by:
- itemin interface- LinkedNode<Item>
- Returns:
- the item
 
- 
setItemDescription copied from interface:LinkedNodeSet the contained item.Replaces whatever was contained before. - Specified by:
- setItemin interface- LinkedNode<Item>
- Parameters:
- item- the new item
 
- 
previousDescription copied from interface:LinkedNodeGet the previous node. ornullif this is the first.- Specified by:
- previousin interface- LinkedNode<Item>
- Returns:
- the predecessor
 
- 
nextDescription copied from interface:LinkedNodeGet the next node. ornullif this is the last.- Specified by:
- nextin interface- LinkedNode<Item>
- Returns:
- the successor
 
- 
insertPreviousDescription copied from interface:LinkedNodeInsert a node containing the given item immediately before this one in the list.- Specified by:
- insertPreviousin interface- LinkedNode<Item>
- Parameters:
- item- the new previous item
 
- 
insertNextDescription copied from interface:LinkedNodeInsert a node containing the given item immediately after this one in the list.- Specified by:
- insertNextin interface- LinkedNode<Item>
- Parameters:
- item- the new next item
 
- 
removeDescription copied from interface:LinkedNodeRemove the node from the list and return its item.- Specified by:
- removein interface- LinkedNode<Item>
- Returns:
- the item
 
- 
removePreviousDescription copied from interface:LinkedNodeRemove the previous node from the list and return its item.- Specified by:
- removePreviousin interface- LinkedNode<Item>
- Returns:
- the old previous item
- Throws:
- NoSuchElementException- if there is no previous node (i.e. this is the first)
 
- 
removeNextDescription copied from interface:LinkedNodeRemove the next node from the list and return its item.- Specified by:
- removeNextin interface- LinkedNode<Item>
- Returns:
- the old next item
- Throws:
- NoSuchElementException- if there is no next node (i.e. this is the last)
 
 
-