MCPcopy
hub / github.com/careercup/ctci / put

Method put

java/Chapter 8/Question8_10/Hash.java:17–32  ·  view source on GitHub ↗
(K key, V value)

Source from the content-addressed store, hash-verified

15 }
16
17 public void put(K key, V value) {
18 int x = hashCodeOfKey(key);
19 if (items[x] == null) {
20 items[x] = new LinkedList<Cell<K, V>>();
21 }
22 LinkedList<Cell<K, V>> collided = items[x];
23 for (Cell<K, V> c : collided) {
24 if (c.equivalent(key)) {
25 collided.remove(c);
26 break;
27 }
28 }
29
30 Cell<K, V> cell = new Cell<K, V>(key, value);
31 collided.add(cell);
32 }
33
34 public V get(K key) {
35 int x = hashCodeOfKey(key);

Callers 15

mainMethod · 0.95
ChapQ3.5.pyFile · 0.80
mainMethod · 0.80
insertStringMethod · 0.80
transformMethod · 0.80
printLongestWordMethod · 0.80
canBuildWordMethod · 0.80
addWordMethod · 0.80
hasCycleMethod · 0.80
declareMethod · 0.80
addUserMethod · 0.80
addBookMethod · 0.80

Calls 4

hashCodeOfKeyMethod · 0.95
equivalentMethod · 0.80
removeMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected