-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNode.java
More file actions
154 lines (127 loc) · 2.76 KB
/
Node.java
File metadata and controls
154 lines (127 loc) · 2.76 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// -------------------------------------------------------------------------
/**
* This is the Node class.
*
* @author wenfeng ren (rwenfeng)
* @version Sep 7, 2014 the general type for node
*/
public class Node
{
// data fields
private int blockSize = -1;
private int position = -1;
private Node next = null;
private Node prev = null;
// ----------------------------------------------------------
/**
* Create a new Node object.
*/
public Node()
{
//
}
// ----------------------------------------------------------
/**
* Create a new Node object with data element.
*
* @param blockSize
* @param position
*/
public Node(int blockSize, int position)
{
this.blockSize = blockSize;
this.position = position;
}
// ----------------------------------------------------------
/**
* get the blockSize.
*
* @return blockSize
*/
public int getBlockSize()
{
return blockSize;
}
// ----------------------------------------------------------
/**
* set blockSize.
*
* @param blockSize
*/
public void setBlockSize(int blockSize)
{
this.blockSize = blockSize;
}
// ----------------------------------------------------------
/**
* get position.
*
* @return position
*/
public int getPosition()
{
return position;
}
// ----------------------------------------------------------
/**
* set position.
*
* @param position
*/
public void setPosition(int position)
{
this.position = position;
}
// ----------------------------------------------------------
/**
* Get the next node.
*
* @return the next node
*/
public Node next()
{
return next;
}
// ----------------------------------------------------------
/**
* set next node.
*
* @param next
*/
public void setNext(Node next)
{
this.next = next;
}
// ----------------------------------------------------------
/**
* Get the prev node.
*
* @return the prev node
*/
public Node prev()
{
return prev;
}
// ----------------------------------------------------------
/**
* set the previous node.
*
* @param prev
*/
public void setPrev(Node prev)
{
this.prev = prev;
}
// ----------------------------------------------------------
/**
* print out the info of the node.
*
* @return str
*/
public String toString()
{
String str = "";
str = "(" + position + "," + blockSize + ")";
return str;
}
}