Returns true if @key already existed in the set before insert
| 187 | |
| 188 | // Returns true if @key already existed in the set before insert |
| 189 | bool insert(uint64_t key) { |
| 190 | std::lock_guard<std::mutex> l(mutex_); |
| 191 | DCHECK(!splits_.empty()); |
| 192 | // Important to lookup first, because entry may be in another split, not the |
| 193 | // one we're currently inserting into. |
| 194 | auto exists = lookupLocked(key); |
| 195 | if (!exists) { |
| 196 | if (splits_.back().size() >= maxSplitSize_) { |
| 197 | addNewSplit(); |
| 198 | } |
| 199 | splits_.back().insert(key); |
| 200 | } |
| 201 | return exists; |
| 202 | } |
| 203 | |
| 204 | void reset() { |
| 205 | std::lock_guard<std::mutex> lock{mutex_}; |