-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHandle.java
More file actions
82 lines (71 loc) · 1.68 KB
/
Handle.java
File metadata and controls
82 lines (71 loc) · 1.68 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
// -------------------------------------------------------------------------
/**
* handle stores a position information of the record returned by memmanager.
*
* @author wenfeng ren (rwenfeng)
* @version Sep 7, 2014
*/
public class Handle
implements Comparable<Handle>
{
// data fields
/**
* the position that MemManager returned.
*/
private int position;
// ----------------------------------------------------------
/**
* Create a new Handle object with initial position.
*
* @param position
* to be set
*/
public Handle(int position)
{
this.position = position;
}
// ----------------------------------------------------------
/**
* get the position stored in handle.
*
* @return position stores in handle
*/
public int getPosition()
{
return position;
}
// ----------------------------------------------------------
/**
* set new position for handle.
*
* @param newPosition
* that needs to be set
*/
public void setPosition(int newPosition)
{
this.position = newPosition;
}
// ----------------------------------------------------------
/**
* set new position for handle.
*
* @param arg
* the handle to compare that needs to be set
* @return 0 or 1 or -1
*/
public int compareTo(Handle arg)
{
if (this.position == arg.getPosition())
{
return 0;
}
else if (this.position > arg.getPosition())
{
return 1;
}
else
{
return -1;
}
}
}