Class LinkedListNode<E>
java.lang.Object
ch.nolix.base.container.linkedlist.LinkedListNode<E>
- Type Parameters:
E- is the type of the element of aLinkedListNode.
A
LinkedListNode contains an element and can have a next node.- Author:
- Silvan Wyss
-
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanbooleanvoidRemoves the next node of the currentLinkedListNode.voidsetElement(E element) Sets the element of the currentLinkedListNode.voidsetNextNode(LinkedListNode<E> nextNode) Sets the next node of the currentLinkedListNode.voidSwaps the element of the currentLinkedListNodewith the element of the next node of the currentLinkedListNode.static <T> LinkedListNode<T> withElement(T element)
-
Method Details
-
withElement
- Type Parameters:
T- is the type of the given element.- Parameters:
element-- Returns:
- a new
LinkedListNodewith the given element. - Throws:
RuntimeException- if the given element is null.
-
contains
- Parameters:
selector-- Returns:
- true if the current
LinkedListNodecontains an element the given selector selects, false otherwise.
-
contains
- Parameters:
element-- Returns:
- true if the current
LinkedListNodecontains the given element, false otherwise.
-
getElement
- Returns:
- the element of the current
LinkedListNode.
-
getNextNode
- Returns:
- the next node of the current
LinkedListNode. - Throws:
RuntimeException- if the currentLinkedListNodedoes not have a next node.
-
hasNextNode
public boolean hasNextNode()- Returns:
- true if the current
LinkedListNodehas a next node, false otherwise.
-
removeNextNode
public void removeNextNode()Removes the next node of the currentLinkedListNode. -
setElement
Sets the element of the currentLinkedListNode.- Parameters:
element-- Throws:
RuntimeException- if the given element is null.
-
setNextNode
Sets the next node of the currentLinkedListNode.- Parameters:
nextNode-- Throws:
RuntimeException- if the given next node is null.
-
swapElementWithNextNode
public void swapElementWithNextNode()Swaps the element of the currentLinkedListNodewith the element of the next node of the currentLinkedListNode.- Throws:
ArgumentDoesNotHaveAttributeException- if the currentLinkedListNodedoes not have a next node.
-