KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jofti > btree > INode


1 /*
2  * Created on 07-Oct-2004
3  *
4  * To change the template for this generated file go to
5  * Window - Preferences - Java - Code Generation - Code and Comments
6  */

7 package com.jofti.btree;
8
9
10
11 import com.jofti.exception.JoftiException;
12 import com.jofti.oswego.concurrent.ReadWriteLock;
13
14
15 /**
16
17  * The interface for Nodes (both internal and leaf) in the BTree.<p>
18  *
19  * @author Steve Woodcock<br>
20  * @version 1.8
21  */

22 public interface INode {
23     
24     
25     /**
26      * Gets the rightmost value for the node. This represents the largest value that this node (or its children)
27      * know about.
28      *
29      * @return The right value.
30      */

31     public abstract Comparable JavaDoc getRightValue();
32
33
34     
35     /**
36      * Sets the right value for the node.
37      *
38      * @param value - the value to use.
39      */

40     public abstract void setRightValue(Comparable JavaDoc value);
41
42
43
44     public abstract boolean contains(Comparable JavaDoc value);
45
46
47     
48     /**
49      *
50      * Inserts the entry into the correct position in the node. The position is ordered by
51      * the Comparableness of its value. If the value in the entry already exists then a
52      * new Entry is not created, it will be added to a leaf node as a member of an existing entry.
53      * <p> If the value is larger than the current right value for the node then the right value is updated.<p>
54      * @param entry - the entry to set.
55      * @return - true if the new Entry required a new entry to be added to the list.
56      * @throws JoftiException
57      */

58     public abstract Object JavaDoc[] insertEntry(NodeEntry entry) throws JoftiException;
59
60
61     /**
62      * Removes an entry from the list of entries in the Node.<p> If the deleted node is the current right value, then the right
63      * value is updated with the next lowest value in the node.<p>
64      *
65      * @param entry - the entry to remove.
66      * @return if a matching entry was found to remove.
67      */

68     public abstract boolean deleteEntry(NodeEntry entry);
69
70
71
72     /**
73      * Splits the current node into two new nodes. The two nodes have a 50/50 split of the entries distributed among them. The higher set
74      * are contained in the new node. In addition, the right values of each node are reset and the next node links are updated. The existing node's
75      * next node link is pointing the the new node and the new node is pointing to the previous right neighbour of the existing node.
76      * <p>
77      * @return the new Node containing half of the existing node's values.
78      */

79     public abstract Node splitNode(Object JavaDoc[] entries) throws JoftiException;
80
81
82     /**
83      * Retrieves the number of entries in the node.<br>
84      * @return entry number.
85      */

86     public abstract int getEntryNumber();
87
88
89     /**
90      * Used to check if the node has exceeded or equaled the maximum number of allowed entries. This is used to
91      * decide whether to spilt the node as part of the insert node functions.
92      *
93      * @return If the number of entries is >= maximum allowed entries.
94      */

95     public abstract boolean isUnderFull();
96
97
98     /**
99      * Checks if the node has any entries.<p>
100      *
101      * @return true if the node has no entries.
102      */

103     public abstract boolean isEmpty();
104
105
106     /**
107      * Checks whether a node has been marked as deleted as a result of a remove. A node is only marked as deleted if it become empty.
108      * At some time later it will then be removed from the tree as other threads traverse it.<p>
109      * @return true if marked as deleted.
110      */

111     public abstract boolean isDeleted();
112
113
114     /**
115      * Sets a node to be deleted. The node is <b>not</b> removed from the tree instead the other threads in the tree
116      * will remove a deleted node as part of their normal traversal process.<p>
117      * @param deleted
118      */

119     public abstract void setDeleted(boolean deleted);
120
121
122     /**
123      * Retrieves the entries in the node as an array.
124      * @return the object array for the entries.
125      */

126     public abstract Object JavaDoc[] getEntries();
127
128
129     /**
130      * Replaces the current entries with a new list of entries. The list passed in is shallow copied
131      * so changes to the originla list do not affect the list in the Node.
132      * <p>
133      * @param entries
134      */

135     public abstract void setEntries(Object JavaDoc[] entries);
136
137
138     /**
139      * Returns the sibling righthand node for this node. This is part of the linking mechanism used to provide
140      * concurrency in the tree.<p>
141      *
142      * @return A nodelink containing the sibling node.
143      */

144     public abstract NodeLink getLinkNode();
145
146
147     /**
148      * Sets a new right hand link for this node.<p>
149      *
150      * @param node - the nodelink to set as the right hand sibling.
151      */

152     public abstract void setLinkNode(NodeLink node);
153
154
155     /**
156      * @return Returns the nodeLock.
157      */

158     public abstract ReadWriteLock getNodeLock();
159     
160     public abstract boolean isLeaf();
161 }
Popular Tags