-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBTree.java
More file actions
81 lines (72 loc) · 1.92 KB
/
BTree.java
File metadata and controls
81 lines (72 loc) · 1.92 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
/*
* B*-Tree interface for the
* Concurrent Search Tree Project for
* Parallel Computing I
*
* Author: David C. Larsen <dcl9934@cs.rit.edu>
* Author: Benjamin David Mayes <bdm8233@rit.edu>
* Date: May 7, 2011
*/
public interface BTree<K extends Comparable,V>
{
/**
* Empty the tree.
*/
public void clear();
/**
* Determine if the <b>key</b> is in the tree.
*
* @param key The key to test for inclusion in the tree.
* @return True if the key is in the tree.
*/
public boolean containsKey( K key );
/**
* Determine if the given <b>value</b> is in the tree.
*
* @param value The value to search for in the tree.
* @return True if the value is in the tree.
*/
public boolean containsValue( V value );
/**
* Grab the value associated with the <b>key</b>.
*
* @param key The key to search for.
* @return The value associated with <b>key</b> if one exists or null
*/
public V get( K key );
/**
* Determine if the tree is empty.
*
* @return True if the tree is empty, false otherwise.
*/
public boolean isEmpty();
/**
* Sets <b>value</b> as the value associated with <b>key</b>.
*
* @param key The key to set the value for.
* @param value The value to set.
* @return The old value associted with <b>key</b>
*/
public V put( K key, V value ); //TODO: Do we want to throw an exception?
/**
* Removes the value associated with <b>key</b>.
*
* @param key The key to remove the value for.
* @return The value formerly associated with <b>key</b> or null.
*/
public V remove( K key );
/**
* Obtains the count of the elements in the tree.
*
* @return The number of (key,value) pairs in the tree.
*/
public int size();
/**
* Gets the root of the tree.
*
* NOTE: It is <b>unwise</b> to modify the node.
*
* @return The root node of this tree.
*/
public Node<K,V> getRoot();
}