-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListNode.java
More file actions
109 lines (96 loc) · 1.86 KB
/
ListNode.java
File metadata and controls
109 lines (96 loc) · 1.86 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
This file creates a node that can be used with LinkedList.java (@see LinkedList.java).
@author Josh Sharpe
Last modified: Oct. 21, 2013.
**/
public class ListNode
{
/**
A node that is intended to be used in a Doubly Linked List.
Attributes: int value, ListNode prev, ListNode next.
**/
private int value;
private ListNode prev;
private ListNode next;
/* Constructors */
/**
Constructor for the ListNode where prev and next are not provided.
@param value the key of the node.
**/
public
ListNode(int value)
{
this.value = value;
this.prev = null;
this.next = null;
}
/**
Constructor for the ListNode where prev and next are provided.
@param value the key of the node.
@param next the node that this node will be pointing to.
@param prev the other node that this node will be pointing to.
**/
public
ListNode(int value, ListNode prev, ListNode next)
{
this.value = value;
this.prev = prev;
this.next = next;
}
/* Getters */
/**
Getter for {@link #value}
@return {@link #value}
**/
public int
getValue()
{
return this.value;
}
/**
Getter for {@link #prev}
@return {@link #prev}
**/
public ListNode
getPrev()
{
return this.prev;
}
/**
Getter for {@link #next}
@return {@link #next}
**/
public ListNode
getNext()
{
return this.next;
}
/* Setters */
/**
Setter for {@link #value}
@param newValue An integer that the value will now be set to.
**/
public void
setValue(int newValue)
{
this.value = value;
}
/**
Setter for {@link #prev}
@param newPrev A new ListNode that the prev will now be set to.
**/
public void
setPrev(ListNode newPrev)
{
this.prev = newPrev;
}
/**
Setter for {@link #next}
@param newNext A new ListNode that the next will now be set to.
**/
public void
setNext(ListNode newNext)
{
this.next = newNext;
}
}//end Node class