-
Notifications
You must be signed in to change notification settings - Fork 19.7k
/
Copy pathSimpleNode.java
59 lines (51 loc) · 1.3 KB
/
SimpleNode.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
package com.thealgorithms.devutils.nodes;
/**
* Simple Node implementation that holds a reference to the next Node.
*
* @param <E> The type of the data held in the Node.
*
* @author <a href="https://github.com/aitorfi">aitorfi</a>
*/
public class SimpleNode<E> extends Node<E> {
/**
* Reference to the next Node.
*/
private SimpleNode<E> nextNode;
/**
* Empty contructor.
*/
public SimpleNode() {
super();
}
/**
* Initializes the Nodes' data.
*
* @param data Value to which data will be initialized.
* @see Node#Node(Object)
*/
public SimpleNode(E data) {
super(data);
}
/**
* Initializes the Nodes' data and next node reference.
*
* @param data Value to which data will be initialized.
* @param nextNode Value to which the next node reference will be set.
*/
public SimpleNode(E data, SimpleNode<E> nextNode) {
super(data);
this.nextNode = nextNode;
}
/**
* @return True if there is a next node, otherwise false.
*/
public boolean hasNext() {
return (nextNode != null);
}
public SimpleNode<E> getNextNode() {
return nextNode;
}
public void setNextNode(SimpleNode<E> nextNode) {
this.nextNode = nextNode;
}
}