MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / get

Method get

706-design-hashmap.rs:25–31  ·  view source on GitHub ↗

Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key */

(&self, key: i32)

Source from the content-addressed store, hash-verified

23
24 /** Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key */
25 fn get(&self, key: i32) -> i32 {
26 if self.map.get(&key).is_some() {
27 *self.map.get(&key).unwrap()
28 } else {
29 -1
30 }
31 }
32
33 /** Removes the mapping of the specified value key if this map contains a mapping for the key */
34 fn remove(&mut self, key: i32) {

Callers 15

transferMethod · 0.80
depositMethod · 0.80
withdrawMethod · 0.80
find_lonelyFunction · 0.80
evaluateFunction · 0.80
sort_even_oddFunction · 0.80
shortest_completing_wordFunction · 0.80
rearrange_charactersFunction · 0.80
add_carMethod · 0.80
dfsFunction · 0.80
intersectFunction · 0.80

Calls

no outgoing calls

Tested by 1

shortest_completing_wordFunction · 0.64