All Packages Class Hierarchy This Package Previous Next Index
Class rebelsky.util.BinaryNode
java.lang.Object
|
+----rebelsky.util.BinaryNode
- public class BinaryNode
- extends Object
A simple node with two references to other nodes. One references
is called left or prev the other is called right or next. These
nodes can be used for singly-linked lists (in which case the prev
link is ignored), doubly-linked lists, and binary trees.
Copyright (c) 1998 Samuel A. Rebelsky. All rights reserved.
- Version:
- 1.0 of March 1998
- Author:
- Samuel A. Rebelsky
Constructor Index
- o
BinaryNode(Object)
- Build a new binary node with null previous and next (left and
right) links.
- o
BinaryNode(Object, BinaryNode)
- Build a new binary node with null previous (left) link and
specified next (right) link.
- o
BinaryNode(Object, BinaryNode, BinaryNode)
- Build a new binary node with specified previous and next (left
and right) links.
Method Index
- o
getContents()
- Get the contents of this node.
- o
getLeft()
- Get the node to the left (if one exists).
- o
getNext()
- Get the next node (if one exists).
- o
getPrev()
- Get the previous node (if one exists).
- o
getRight()
- Get the right node (if one exists).
- o
setContents(Object)
- Set the contents of this node.
- o
setLeft(BinaryNode)
- Set the node to the left.
- o
setNext(BinaryNode)
- Set the next link.
- o
setPrev(BinaryNode)
- Set the previous link.
- o
setRight(BinaryNode)
- Set the node to the right.
Constructors
o
BinaryNode
public BinaryNode(Object contents)
- Build a new binary node with null previous and next (left and
right) links.
o
BinaryNode
public BinaryNode(Object contents,
BinaryNode next)
- Build a new binary node with null previous (left) link and
specified next (right) link.
o
BinaryNode
public BinaryNode(Object contents,
BinaryNode prev,
BinaryNode next)
- Build a new binary node with specified previous and next (left
and right) links.
Methods
o
getContents
public Object getContents()
- Get the contents of this node.
Precondition:
(none)
Postcondition:
The contents are returned.
Postcondition:
The node is unaffected.
o
getPrev
public BinaryNode getPrev()
- Get the previous node (if one exists).
Precondition:
(none)
Postcondition:
The previous node is returned. If there is no previous node,
returns null.
Postcondition:
The node is unaffected.
o
getLeft
public BinaryNode getLeft()
- Get the node to the left (if one exists).
Precondition:
(none)
Postcondition:
The previous node is returned. If there is no previous node,
returns null.
Postcondition:
The node is unaffected.
o
getNext
public BinaryNode getNext()
- Get the next node (if one exists).
Precondition:
(none)
Postcondition:
The next node is returned. If there is no next node,
returns null.
Postcondition:
The node is unaffected.
o
getRight
public BinaryNode getRight()
- Get the right node (if one exists).
Precondition:
(none)
Postcondition:
The right node is returned. If there is no right node,
returns null.
Postcondition:
The node is unaffected.
o
setContents
public Object setContents(Object new_contents)
- Set the contents of this node.
Precondition:
(none)
Postcondition:
The contents are changed.
Postcondition:
The old contents are returned.
o
setPrev
public BinaryNode setPrev(BinaryNode new_prev)
- Set the previous link.
Precondition:
(none)
Postcondition:
The previous link is set.
Postcondition:
The former previous node is returned. If there was no former
previous node, returns null.
o
setLeft
public BinaryNode setLeft(BinaryNode new_prev)
- Set the node to the left.
Precondition:
(none)
Postcondition:
The left link is set.
Postcondition:
The old left node is returned. If there is no old left node,
returns null.
o
setNext
public BinaryNode setNext(BinaryNode new_next)
- Set the next link.
Precondition:
(none)
Postcondition:
The next link is set.
Postcondition:
The former next node is returned. If there was no former
next node, returns null.
o
setRight
public BinaryNode setRight(BinaryNode new_next)
- Set the node to the right.
Precondition:
(none)
Postcondition:
The right link is set.
Postcondition:
The old right node is returned. If there is no old right node,
returns null.
All Packages Class Hierarchy This Package Previous Next Index