public class DoubleNode
extends java.lang.Object
Node
,
BooleanNode
,
ByteNode
,
CharNode
,
FloatNode
,
IntNode
,
LongNode
,
ShortNode
Constructor and Description |
---|
DoubleNode(double initialData,
DoubleNode initialLink)
Initialize a node with a specified initial data and link to the next
node.
|
Modifier and Type | Method and Description |
---|---|
void |
addNodeAfter(double item)
Modification method to add a new node after this node.
|
double |
getData()
Accessor method to get the data from this node.
|
DoubleNode |
getLink()
Accessor method to get a reference to the next node after this node.
|
static DoubleNode |
listCopy(DoubleNode source)
Copy a list.
|
static DoubleNode[] |
listCopyWithTail(DoubleNode source)
Copy a list, returning both a head and tail reference for the copy.
|
static int |
listLength(DoubleNode head)
Compute the number of nodes in a linked list.
|
static DoubleNode[] |
listPart(DoubleNode start,
DoubleNode end)
Copy part of a list, providing a head and tail reference for the new copy.
|
static DoubleNode |
listPosition(DoubleNode head,
int position)
Find a node at a specified position in a linked list.
|
static DoubleNode |
listSearch(DoubleNode head,
double target)
Search for a particular piece of data in a linked list.
|
void |
removeNodeAfter()
Modification method to remove the node after this node.
|
void |
setData(double newData)
Modification method to set the data in this node.
|
void |
setLink(DoubleNode newLink)
Modification method to set the link to the next node after this node.
|
public DoubleNode(double initialData, DoubleNode initialLink)
initialData
- the initial data of this new nodeinitialLink
- a reference to the node after this new node--this reference may be null
to indicate that there is no node after this new node.public void addNodeAfter(double item)
item
- the data to place in the new nodejava.lang.OutOfMemoryError
- Indicates that there is insufficient memory for a new
DoubleNode.public double getData()
public DoubleNode getLink()
public static DoubleNode listCopy(DoubleNode source)
source
- the head of a linked list that will be copied (which may be
an empty list in where source is null)java.lang.OutOfMemoryError
- Indicates that there is insufficient memory for the new list.public static DoubleNode[] listCopyWithTail(DoubleNode source)
source
- the head of a linked list that will be copied (which may be
an empty list in where source is null)java.lang.OutOfMemoryError
- Indicates that there is insufficient memory for the new list.public static int listLength(DoubleNode head)
head
- the head reference for a linked list (which may be an empty list
with a null head)public static DoubleNode[] listPart(DoubleNode start, DoubleNode end)
start
- reference to start node of a linked listend
- reference to end node of a linked listjava.lang.IllegalArgumentException
- Indicates that start and end are not references
to nodes on the same list.java.lang.NullPointerException
- Indicates that start is null.java.lang.OutOfMemoryError
- Indicates that there is insufficient memory for the new list.public static DoubleNode listPosition(DoubleNode head, int position)
head
- the head reference for a linked list (which may be an empty list in
which case the head is null)position
- a node numberjava.lang.IllegalArgumentException
- Indicates that position is not positive.public static DoubleNode listSearch(DoubleNode head, double target)
head
- the head reference for a linked list (which may be an empty list in
which case the head is null)target
- a piece of data to search forpublic void removeNodeAfter()
java.lang.NullPointerException
- Indicates that this was the tail node of the list, so there is nothing
after it to remove.public void setData(double newData)
newData
- the new data to place in this nodepublic void setLink(DoubleNode newLink)
newLink
- a reference to the node that should appear after this node in the linked
list (or the null reference if there is no node after this node)