-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
49 lines (39 loc) · 788 Bytes
/
Node.java
File metadata and controls
49 lines (39 loc) · 788 Bytes
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
47
48
49
import java.util.ArrayList;
public class Node {
private int key;
private ArrayList<Node> pointerList;
public Node (){
pointerList = new ArrayList<Node> ();
}
public Node (int key, double level) {
int lcap = (int) level;
this.key = key;
pointerList = new ArrayList<Node> ();
for (int i = 0; i < lcap; i++) {
pointerList.add(new Node());
}
}
public int getKey(){
return key;
}
public Node getNext(int i) {
return pointerList.get(i);
}
public void setNext(int i, Node x) {
if (pointerList.get(i) == null) {
pointerList.add(i, x);
}
else {
pointerList.set(i, x);
}
}
public void setValue(int k) {
key = k;
}
public void addToList(Node n) {
pointerList.add(n);
}
public int getMaxUsedLevel() {
return pointerList.size()-1;
}
}