File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ class HashTable {
35
35
std::vector<K> keys ();
36
36
std::vector<T> values ();
37
37
38
- T& operator [](K key);
38
+ T& operator [](const K& key);
39
39
T& pop (K key);
40
40
bool has_key (K key);
41
41
@@ -103,7 +103,7 @@ void HashTable<K, T>::set_default(T default_value_) {
103
103
}
104
104
105
105
template <hashable K, typename T>
106
- T& HashTable<K, T>::operator [](K key) {
106
+ T& HashTable<K, T>::operator [](const K& key) {
107
107
LinkedList<std::pair<K, T>>& key_list =
108
108
hash_vector[(hasher (key)) % array_length];
109
109
@@ -151,7 +151,7 @@ T& HashTable<K, T>::pop(K key) {
151
151
return value;
152
152
}
153
153
}
154
- throw std::runtime_error (" deleting a key that doesn't exist " );
154
+ throw std::runtime_error (" out_of_range " );
155
155
}
156
156
157
157
template <hashable K, typename T>
You can’t perform that action at this time.
0 commit comments