|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.mhhe.clrs2e.BTree.Node
Private inner class for a B-tree node.
Field Summary | |
BTree.Node[] |
c
Pointers to the children, if this node is not a leaf. |
com.mhhe.clrs2e.DynamicSetElement[] |
key
Array of the keys stored in the node. |
boolean |
leaf
true if this node is a leaf,
false if this node is an interior node. |
int |
n
The number of keys stored in the node. |
Constructor Summary | |
BTree.Node(int n,
boolean leaf)
Initializes the instance variables, including allocating the c array if this node is not a leaf. |
Method Summary | |
BTree.BTreeHandle |
BTreeInsertNonfull(com.mhhe.clrs2e.DynamicSetElement k)
Inserts a new element in this node, which is assumed to be nonfull. |
BTree.BTreeHandle |
BTreeSearch(java.lang.Comparable k)
Searches for a dynamic set element with a given key, starting at this node. |
void |
BTreeSplitChild(BTree.Node x,
int i)
Splits this node, which is a full child of its parent, which is in turn a nonfull internal node. |
void |
delete(java.lang.Comparable k)
Deletes an element with a given key from the subtree rooted at this node. |
private void |
deleteFromInternalNode(int i)
Deletes a given key from this node, which is assumed to be an internal node and already in memory. |
private void |
deleteFromLeaf(java.lang.Comparable k)
Deletes an element with a given key from this node, which is assumed to be a leaf and already in memory. |
private void |
diskRead()
Reads a disk block. |
void |
diskWrite()
Writes a disk block. |
private void |
ensureFullEnough(int i)
Ensures that a given child of this node child has at least t keys. |
private com.mhhe.clrs2e.DynamicSetElement |
findGreatestInSubtree()
Finds the dynamic set element with the greatest key in the subtree rooted at this node. |
private com.mhhe.clrs2e.DynamicSetElement |
findSmallestInSubtree()
Finds the dynamic set element with the smallest key in the subtree rooted at this node. |
private void |
free()
Frees this node. |
java.lang.String |
walk(int depth)
Returns the String representation of the
subtree rooted at this node. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public int n
public com.mhhe.clrs2e.DynamicSetElement[] key
public BTree.Node[] c
null
.
public boolean leaf
true
if this node is a leaf,
false
if this node is an interior node.
Constructor Detail |
public BTree.Node(int n, boolean leaf)
c
array if this node is not a leaf.
n
- How many of keys are to be stored in this node.leaf
- true
if this node is a leaf,
false
if this node is an interior node.Method Detail |
private void diskRead()
public void diskWrite()
private void free()
public BTree.BTreeHandle BTreeSearch(java.lang.Comparable k)
k
- The key.
null
if there is no match.public void BTreeSplitChild(BTree.Node x, int i)
x
- This node's parent.i
- This node is child c[i]
of
x
.public BTree.BTreeHandle BTreeInsertNonfull(com.mhhe.clrs2e.DynamicSetElement k)
k
- The new element to be inserted.public void delete(java.lang.Comparable k)
k
- The key of an element to be deleted.private void deleteFromLeaf(java.lang.Comparable k)
k
- The key of the element to be deleted.private void deleteFromInternalNode(int i)
i
- key[i]
is deleted from this node.private com.mhhe.clrs2e.DynamicSetElement findGreatestInSubtree()
private com.mhhe.clrs2e.DynamicSetElement findSmallestInSubtree()
private void ensureFullEnough(int i)
t
keys. Assumes that this node and the child
are already in memory.
i
- The i
th child of this node is the one
that will have at last t
keys.public java.lang.String walk(int depth)
String
representation of the
subtree rooted at this node. Represents the depth of each
node by two spaces per depth preceding the
String
representation of the node.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |