Package Struct
Class ListNode<T>
java.lang.Object
Struct.ListNode<T>
- Type Parameters:
T
- The type of the value stored in each node.
Represents a node in a doubly linked list, which can be navigated in both directions: forward and backward.
Each node contains a value and links to the previous and next nodes in the list.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Sahasrad Chippa
-
Method Summary
Modifier and TypeMethodDescriptionCreates a string representation of all values from this node backwards until the list start.Creates a string representation of all values from this node forwards until the list end.forwardString
(String prefix, String delim, String suffix) Generates a string from this node values moving forward, formatted with specified delimiters.toString()
Provides a string representation of this node showing connections to its previous and next node values.
-
Method Details
-
toString
Provides a string representation of this node showing connections to its previous and next node values. This method is particularly useful for debugging purposes to visualize the linkage of the node within a list. -
forwardString
Creates a string representation of all values from this node forwards until the list end. Uses default formatting with brackets and commas. Runs inO(n)
time.- Returns:
- A formatted string of node values forwards.
-
backwardString
Creates a string representation of all values from this node backwards until the list start. Uses default formatting with brackets and commas. Runs inO(n)
time.- Returns:
- A formatted string of node values backwards.
-
forwardString
Generates a string from this node values moving forward, formatted with specified delimiters. Runs inO(n)
time.- Parameters:
prefix
- The prefix to start the list representation.delim
- The delimiter to separate node values.suffix
- The suffix to end the list representation.- Returns:
- A string representation of forward node values with custom formatting.
-