-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinnerNode.java
More file actions
46 lines (37 loc) · 1.02 KB
/
innerNode.java
File metadata and controls
46 lines (37 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.util.ArrayList;
import java.util.List;
public class innerNode extends genericNode {
// m nodes
protected ArrayList<genericNode> childList; // m+1 childList
public innerNode(Double key, genericNode child0, genericNode child1) {
LeafNodeCheck = false;
keyList = new ArrayList<Double>();
keyList.add(key);
childList = new ArrayList<genericNode>();
childList.add(child0);
childList.add(child1);
}
public innerNode(List<Double> newKeys, List<genericNode> newChildren) {
LeafNodeCheck = false;
keyList = new ArrayList<Double>(newKeys);
childList = new ArrayList<genericNode>(newChildren);
}
/**
* insert the entry into this node at the specified index so that it still
* remains sorted
*
* @param dict
* @param index
*/
public void InsertAndSort(myDict dict, int index) {
Double key = dict.key;
genericNode child = dict.Node;
if (index >= keyList.size()) {
keyList.add(key);
childList.add(child);
} else {
keyList.add(index, key);
childList.add(index+1, child);
}
}
}