-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkipListEntry.java
More file actions
49 lines (36 loc) · 1.11 KB
/
SkipListEntry.java
File metadata and controls
49 lines (36 loc) · 1.11 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
package hw2;
public class SkipListEntry {
private String key;
private Integer value;
public int pos; // I added this to print the skiplist "nicely"
public SkipListEntry up, down, left, right;
public static String negInf = new String("-oo"); // -inf key value
public static String posInf = new String("+oo"); // +inf key value
public SkipListEntry(String k, Integer v) {
key = k;
value = v;
up = down = left = right = null;
}
public Integer getValue() { return value; }
public String getKey() { return key; }
public Integer setValue(Integer val) {
Integer oldValue = value;
value = val;
return oldValue;
}
@Override
public boolean equals(Object o) {
SkipListEntry ent;
try {
ent = (SkipListEntry) o; // Test if o is a SkipListEntry...
}
catch (ClassCastException ex) {
return false;
}
return (ent.getKey() == key) && (ent.getValue() == value);
}
@Override
public String toString() {
return "(" + key + "," + value + ")";
}
}