-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNodeType.java
More file actions
74 lines (65 loc) · 1.44 KB
/
NodeType.java
File metadata and controls
74 lines (65 loc) · 1.44 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* Simple node type for a doubly-linked list.
*
* @param <T> element type (must be Comparable)
*/
public class NodeType<T extends Comparable<T>> {
private T info;
private NodeType<T> next;
private NodeType<T> back;
/**
* Create an empty node with null links and no info set.
*/
public NodeType() {
next = null;
back = null;
}
/**
* Return the payload stored in this node.
*
* @return the info value (may be null)
*/
public T getInfo() {
return info;
}
/**
* Set the payload for this node.
*
* @param info value to store in the node
*/
public void setInfo(T info) {
this.info = info;
}
/**
* Get the next node in the list.
*
* @return reference to the next node, or null if none
*/
public NodeType<T> getNext() {
return next;
}
/**
* Set the next node reference.
*
* @param next node to set as next
*/
public void setNext(NodeType<T> next) {
this.next = next;
}
/**
* Get the previous (back) node in the list.
*
* @return reference to the previous node, or null if none
*/
public NodeType<T> getBack() {
return back;
}
/**
* Set the previous (back) node reference.
*
* @param back node to set as previous
*/
public void setBack(NodeType<T> back) {
this.back = back;
}
}