-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBTreeOperation.java
More file actions
47 lines (40 loc) · 970 Bytes
/
BTreeOperation.java
File metadata and controls
47 lines (40 loc) · 970 Bytes
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
public class BTreeOperation<K,V>
{
public char operation;
public K key;
public V value;
public V result;
public boolean resultPut;
public BTreeOperation( char operation, K key, V value ){
this.operation = operation;
this.key = key;
this.value = value;
result = null;
resultPut = false;
}
public BTreeOperation( char operation, K key )
{
this( operation, key, null );
}
public BTreeOperation( char operation )
{
this( operation, null );
}
public void putResult( V result )
{
this.result = result;
resultPut = true;
notify();
}
public V getResult()
{
// Wait until we get the result from the tree.
try{
while( !resultPut ) {
wait();
}
// Interrupted? Return what we have.
} catch( InterruptedException ie ) {}
return result;
}
}