Insert entry if entry with same key not present. key should not be null. Return true if insert occurred.
| 96 | /// Insert entry if entry with same key not present. key should not be null. |
| 97 | /// Return true if insert occurred. |
| 98 | bool InsertIfNotPresent(const K key, const V& val) { |
| 99 | DCHECK_LT(size_, capacity_); |
| 100 | Entry* entry = FindEntry(key); |
| 101 | if (entry->key != NULL) return false; |
| 102 | entry->key = key; |
| 103 | entry->val = val; |
| 104 | ++size_; |
| 105 | return true; |
| 106 | } |
| 107 | |
| 108 | /// Try to find entry, and insert default_val if not present. Return a pointer to the |
| 109 | /// value. key should not be null. |
no outgoing calls