|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.colorado.nodes.IntNode
public class IntNode
An IntNode provides a node for a linked list with integer data in each node.
Node,
BooleanNode,
ByteNode,
CharNode,
DoubleNode,
FloatNode,
LongNode,
ShortNode| Constructor Summary | |
|---|---|
IntNode(int initialData,
IntNode initialLink)
Initialize a node with a specified initial data and link to the next node. |
|
| Method Summary | |
|---|---|
void |
addNodeAfter(int item)
Modification method to add a new node after this node. |
int |
getData()
Accessor method to get the data from this node. |
IntNode |
getLink()
Accessor method to get a reference to the next node after this node. |
static IntNode |
listCopy(IntNode source)
Copy a list. |
static IntNode[] |
listCopyWithTail(IntNode source)
Copy a list, returning both a head and tail reference for the copy. |
static int |
listLength(IntNode head)
Compute the number of nodes in a linked list. |
static IntNode[] |
listPart(IntNode start,
IntNode end)
Copy part of a list, providing a head and tail reference for the new copy. |
static IntNode |
listPosition(IntNode head,
int position)
Find a node at a specified position in a linked list. |
static IntNode |
listSearch(IntNode head,
int 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(int newData)
Modification method to set the data in this node. |
void |
setLink(IntNode newLink)
Modification method to set the link to the next node after this node. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IntNode(int initialData,
IntNode 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.| Method Detail |
|---|
public void addNodeAfter(int item)
item - the data to place in the new nodejava.lang.OutOfMemoryError - Indicates that there is insufficient memory for a new
IntNode.public int getData()
- - none
public IntNode getLink()
- - none
public static IntNode listCopy(IntNode 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 IntNode[] listCopyWithTail(IntNode 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(IntNode head)
head - the head reference for a linked list (which may be an empty list
with a null head)
public static IntNode[] listPart(IntNode start,
IntNode end)
start/end - references to two nodes of a linked listcopyHead/copyTail - the method sets these to refer to the head and tail node of the new
list that is createdjava.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 IntNode listPosition(IntNode 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 IntNode listSearch(IntNode head,
int 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 for
public void removeNodeAfter()
- - nonejava.lang.NullPointerException - Indicates that this was the tail node of the list, so there is nothing
after it to remove.public void setData(int newData)
newData - the new data to place in this nodepublic void setLink(IntNode 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)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||