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

Class Node

lab08/src/hashmap/ULLMap.java:84–117  ·  view source on GitHub ↗

Represents one node in the linked list that stores the key-value pairs in the dictionary.

Source from the content-addressed store, hash-verified

82 * in the dictionary.
83 */
84 private class Node {
85
86 /**
87 * Stores KEY as the key in this key-value pair, VAL as the value, and
88 * NEXT as the next node in the linked list.
89 */
90 Node(K k, V v, Node n) {
91 key = k;
92 val = v;
93 next = n;
94 }
95
96 /**
97 * Returns the Node in this linked list of key-value pairs whose key
98 * is equal to KEY, or null if no such Node exists.
99 */
100 Node get(K k) {
101 if (k != null && k.equals(key)) {
102 return this;
103 }
104 if (next == null) {
105 return null;
106 }
107 return next.get(k);
108 }
109
110 /** Stores the key of the key-value pair of this node in the list. */
111 K key;
112 /** Stores the value of the key-value pair of this node in the list. */
113 V val;
114 /** Stores the next Node in the linked list. */
115 Node next;
116
117 }
118
119 /** An iterator that iterates over the keys of the dictionary. */
120 private class ULLMapIter implements Iterator<K> {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected