This bool represents whether the key was found in the map or not.
(&self, k: K, f: F)
| 601 | |
| 602 | // This bool represents whether the key was found in the map or not. |
| 603 | pub fn get_or_create_with_flag<F>(&self, k: K, f: F) -> (V, bool) |
| 604 | where |
| 605 | F: FnOnce() -> V, |
| 606 | V: Clone, |
| 607 | { |
| 608 | let index = self.hash_key(&k); |
| 609 | let mut ht = self.hash_table_list[index].lock().unwrap(); |
| 610 | match ht.get(&k) { |
| 611 | Some(v) => (v.clone(), true), |
| 612 | None => { |
| 613 | let new_v = f(); |
| 614 | ht.insert(k, new_v.clone()); |
| 615 | (new_v, false) |
| 616 | } |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | // This bool represents whether the key was found in the map or not. |
| 621 | pub fn get_or_try_create_with_flag<F, E>(&self, k: K, f: F) -> Result<(V, bool), E> |