MCPcopy Create free account
hub / github.com/Berkeley-CS61B/skeleton-sp23 / put

Method put

lab08/src/hashmap/ULLMap.java:43–56  ·  view source on GitHub ↗

Inserts the key-value pair of KEY and VALUE into this map, replacing the previous value associated to KEY, if any.

(K key, V val)

Source from the content-addressed store, hash-verified

41 * replacing the previous value associated to KEY, if any.
42 */
43 public void put(K key, V val) {
44 if (list != null) {
45 Node lookup = list.get(key);
46 if (lookup == null) {
47 list = new Node(key, val, list);
48 size = size + 1;
49 } else {
50 lookup.val = val;
51 }
52 } else {
53 list = new Node(key, val, list);
54 size = size + 1;
55 }
56 }
57
58 /**
59 * Returns true if and only if this dictionary contains KEY as the

Callers

nothing calls this directly

Calls 1

getMethod · 0.65

Tested by

no test coverage detected