-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinkedNode.java
More file actions
68 lines (59 loc) · 1.31 KB
/
LinkedNode.java
File metadata and controls
68 lines (59 loc) · 1.31 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
package com.company;
/**
* Node class used in linked data structure implementations.
*
* DO NOT ALTER THIS FILE!!
*
* @author CS 1332 TAs
* @version 1.0
*/
public class LinkedNode<T> {
private T data;
private LinkedNode<T> next;
/**
* Create a new LinkedNode with the given data object and next node.
*
* @param data data to store in the node
* @param next the next node
*/
public LinkedNode(T data, LinkedNode<T> next) {
this.data = data;
this.next = next;
}
/**
* Create a new LinkedNode with the given data object and no next node.
*
* @param data data to store in this node
*/
public LinkedNode(T data) {
this(data, null);
}
/**
* Get the data stored in the node.
*
* @return data in this node.
*/
public T getData() {
return data;
}
/**
* Get the next node.
*
* @return next node.
*/
public LinkedNode<T> getNext() {
return next;
}
/**
* Set the next node.
*
* @param next new next node.
*/
public void setNext(LinkedNode<T> next) {
this.next = next;
}
@Override
public String toString() {
return "Node containing: " + data;
}
}