-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.java
66 lines (53 loc) · 1.26 KB
/
Node.java
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import java.util.ArrayList;
public class Node {
private int count;
private final int ITEM_ID;
private ArrayList<Node> NEXT_NODES;
private Node PREV_NODE;
private Node nextItemPointer;
public Node(int itemid) {
NEXT_NODES = new ArrayList<>();
ITEM_ID = itemid;
count = 1;
}
public boolean incrementCount(int value) {
count += value;
return true;
}
public boolean decrementCount(int value) {
count -= value;
return true;
}
public boolean setCount(int value) {
count = value;
return true;
}
public int getCount() {
return count;
}
public boolean setNext(Node nextNode) {
nextNode.setPrevious(this);
NEXT_NODES.add(nextNode);
return true;
}
public boolean setPrevious(Node nextNode) {
PREV_NODE = nextNode;
return true;
}
public ArrayList<Node> getNext() {
return NEXT_NODES;
}
public Node getPrevious() {
return PREV_NODE;
}
public int getId() {
return ITEM_ID;
}
public boolean setNextPointer(Node n) {
nextItemPointer = n;
return true;
}
public Node getNextPointer() {
return nextItemPointer;
}
}