-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataStructureADT.java
More file actions
39 lines (34 loc) · 1.47 KB
/
DataStructureADT.java
File metadata and controls
39 lines (34 loc) · 1.47 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
/**
* A data structure that can store at as many key,value pairs as needed.
*
* CAUTION: The methods in this interface are similar,
* but not exactly the same as given in p1 and p2.
*
* May not add any public members to ADT or your implementation.
*
* @author deppeler
*
* @param <K> The key must not be null and must be Comparable.
* @param <V> The data value associated with a given key.
*/
public interface DataStructureADT<K extends Comparable<K>, V> {
// Add the key,value pair to the data structure and increase the number of keys.
// If key is null, throw IllegalNullKeyException;
// If key is already in data structure, throw DuplicateKeyException();
void insert(K key, V value) throws IllegalNullKeyException, DuplicateKeyException;
// If key is found,
// remove the key,value pair from the data structure
// decrease number of keys.
// return true
// If key is null, throw IllegalNullKeyException
// If key is not found, return false
boolean remove(K key) throws IllegalNullKeyException;
// Returns the value associated with the specified key
// Does not remove key or decrease number of keys
//
// If key is null, throw IllegalNullKeyException
// If key is not found, throw KeyNotFoundException().
V get(K key) throws IllegalNullKeyException, KeyNotFoundException;
// Returns the number of key,value pairs in the data structure
int numKeys();
}