-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSinglyLinkedListNode.java
62 lines (55 loc) · 1.2 KB
/
SinglyLinkedListNode.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
/**
* Node class used for implementing the SinglyLinkedList.
*
* DO NOT MODIFY THIS FILE!!
*
* @author CS 1332 TAs
* @version 1.0
*/
public class SinglyLinkedListNode<T> {
private T data;
private SinglyLinkedListNode<T> next;
/**
* Constructs a new SinglyLinkedListNode with the given data and next node
* reference.
*
* @param data the data stored in the new node
* @param next the next node in the list
*/
SinglyLinkedListNode(T data, SinglyLinkedListNode<T> next) {
this.data = data;
this.next = next;
}
/**
* Creates a new SinglyLinkedListNode with only the given data.
*
* @param data the data stored in the new node
*/
SinglyLinkedListNode(T data) {
this(data, null);
}
/**
* Gets the data.
*
* @return the data
*/
T getData() {
return data;
}
/**
* Gets the next node.
*
* @return the next node
*/
SinglyLinkedListNode<T> getNext() {
return next;
}
/**
* Sets the next node.
*
* @param next the new next node
*/
void setNext(SinglyLinkedListNode<T> next) {
this.next = next;
}
}