-
Notifications
You must be signed in to change notification settings - Fork 0
/
Map.java
64 lines (55 loc) · 1.78 KB
/
Map.java
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
/**
* This interface represents a subset of the official Java Map interface
* created for the purpose of completing the Data Structures Map projects
*
* @author Tom Bredemeier
* @version January 28, 2018
*/
public interface Map<K, V>
{
/**
* Returns the number of entries in this Map.
*/
public int size();
/**
* Returns true if this Map is empty; otherwise, returns false.
*/
public boolean isEmpty();
/**
* Returns true if an entry in this Map with key exists;
* Returns false otherwise.
* @throws IllegalArgumentException if key is null
*/
public boolean containsKey(K key);
/**
* Returns true if an entry in this Map with value exists;
* Returns false otherwise.
*/
public boolean containsValue(V value);
/**
* If an entry in this map with a key exists then the value associated
* with that entry is returned; otherwise null is returned.
* @throws IllegalArgumentException if key is null
*/
public V get(K key);
/**
* If an entry in this map with key already exists then the value
* associated with that entry is replaced by value and the original
* value is returned; otherwise, adds the (key, value) pair to the map
* and returns null.
* @throws IllegalArgumentException if key is null
*/
public V put(K key, V value);
/**
* If an entry in this map with key exists then the entry is removed
* from the map and the value associated with that entry is returned;
* otherwise null is returned.
* @throws IllegalArgumentException if key is null
*/
public V remove(K key);
/**
* Removes all of the mappings from this map. The map will be empty
* after this call returns.
*/
public void clear();
}