-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLPHashMap.java
More file actions
149 lines (123 loc) · 3.2 KB
/
Copy pathLPHashMap.java
File metadata and controls
149 lines (123 loc) · 3.2 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import java.util.Map;
import java.util.Set;
import java.util.Collection;
import java.util.Iterator;
import java.util.Spliterator;
import java.util.function.Consumer;
/** Base implementation of MapJHU using linear probe open addressing.
* @author CS226 Staff, Spring 2016
* @param <K> the base type of the keys
* @param <V> the base type of the values
*/
public class LPHashMap<K, V> implements MapJHU<K, V>,
Iterable<LPMapEntry<K, V>> {
/* Custom methods --------------------------------- */
private float lf;
/** Create an empty open addressing hash map implementation with capacity 5.
* @param max the maximum load factor, 0 < maxLoad <= 1
*/
public LPHashMap(float max) {
this.lf = max;
}
/** Get the maximum load factor.
* @return the load factor
*/
public float getMaxLoad() {
return 0;
}
/** Get the current load factor.
* @return the load factor, should be 0 < lf <= 1
*/
public float getLoad() {
return 0;
}
/** Get the table capacity (total # of slots).
* @return the capacity
*/
public int getCapacity() {
return 0;
}
/** Rehash the entries to a new table size.
* @param cap the capacity of the table after rehashing, cap > size()
*/
public void rehash(int cap) {
}
/** Get the number of tombstones currently in the map (markers
* left behind when values were deleted, until the slot is reused).
* @return the number
*/
public int ghosts() {
return 0;
}
/* Methods from the MapJHU interface ---------------- */
@Override
public int size() {
return 0;
}
@Override
public void clear() {
}
@Override
public boolean isEmpty() {
return true;
}
@Override
public boolean hasKey(K key) {
return false;
}
@Override
public boolean hasValue(V value) {
return false;
}
@Override
public V get(K key) {
return null;
}
@Override
public V put(K key, V value) {
return null;
}
@Override
public V remove(K key) {
return null;
}
// You may use HashSet within this method.
@Override
public Set<Map.Entry<K, V>> entries() {
return null;
}
// You may use HashSet within this method.
@Override
public Set<K> keys() {
return null;
}
@Override
public Collection<V> values() {
return null;
}
/* -------------- from Object -------- YOU DON'T HAVE TO IMPLEMENT
@Override
public boolean equals(Object o) {
return false;
}
@Override
public int hashCode() {
return 0;
}
*/
/* ---------- from Iterable ---------- */
@Override
public Iterator<LPMapEntry<K, V>> iterator() {
return null;
}
@Override
public void forEach(Consumer<? super LPMapEntry<K, V>> action) {
// you do not have to implement this
}
@Override
public Spliterator<LPMapEntry<K, V>> spliterator() {
// you do not have to implement this
return null;
}
/* ----- insert the HashMapIterator inner class here ----- */
}