-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLockFreeSetContains.java
More file actions
63 lines (60 loc) · 1.49 KB
/
LockFreeSetContains.java
File metadata and controls
63 lines (60 loc) · 1.49 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
public class LockFreeSetContains extends Method {
private int pc = 0;
private LockFreeSetNode curr = null, succ = null;
boolean returnValue = false;
boolean marked;
private LockFreeSetNode head;
private char item;
LockFreeSetContains(LockFreeSetNode h, char i, int t) {
super(t);
head = h;
item = i;
}
public String getName() {
return "Contains";
}
public String getArgStr() {
return String.valueOf(item);
}
public void step() {
switch(pc) {
case 0:
log("curr = head");
curr = head;
pc++;
break;
case 1:
if (curr.getContents() < item) {
log("curr.getContents(" + curr.getContentsString() + ") < item " + item +" is true");
curr = curr.getNext();
log("curr = curr.getNext()");
} else {
log("curr.getContents(" + curr.getContentsString() + ") < item " + item +" is false");
pc++;
}
break;
case 2:
log("succ = curr.next.get(marked);");
succ = curr.getNext();
marked = curr.getMarked();
pc++;
break;
case 3:
if(curr.getContents() == item && !marked) {
log("curr.key == key " + item + " && !marked[i] is true");
log("returning true");
returnValue = true;
} else {
log("curr.key == key " + item + " && !marked[i] is false");
log("returning false");
returnValue = false;
}
completed = true;
pc++;
break;
}
}
public boolean getReturnStatus() {
return returnValue;
}
};