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

Method put

lab07/src/ULLMap.java:38–50  ·  view source on GitHub ↗

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

(K key, V val)

Source from the content-addressed store, hash-verified

36 /** Inserts the key-value pair of KEY and VALUE into this dictionary,
37 * replacing the previous value associated to KEY, if any. */
38 public void put(K key, V val) {
39 if (list != null) {
40 Entry lookup = list.get(key);
41 if (lookup == null) {
42 list = new Entry(key, val, list);
43 } else {
44 lookup.val = val;
45 }
46 } else {
47 list = new Entry(key, val, list);
48 size = size + 1;
49 }
50 }
51
52 /** Returns true if and only if this dictionary contains KEY as the
53 * key of some key-value pair. */

Callers

nothing calls this directly

Calls 1

getMethod · 0.65

Tested by

no test coverage detected