* Adds or overwrites a key-value pair in the B+ tree. * @param key the key is used to determine the sort order of * data in the tree. * @param value data to associate with the key (optional) * @param overwrite Whether to overwrite an existing key-value pair * (default: t
(key: K, value: V, overwrite?: boolean)
| 171 | * has data that does not affect its sort order. |
| 172 | */ |
| 173 | set(key: K, value: V, overwrite?: boolean): boolean { |
| 174 | if (this._root.isShared) this._root = this._root.clone() |
| 175 | const result = this._root.set(key, value, overwrite, this) |
| 176 | if (result === true || result === false) return result |
| 177 | // Root node has split, so create a new root node. |
| 178 | this._root = new BNodeInternal<K, V>([this._root, result]) |
| 179 | return true |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Returns true if the key exists in the B+ tree, false if not. |