skiplist: Sanity check inserted entries

This commit is contained in:
Richard Hansen 2021-04-12 01:35:27 -04:00
parent 9e2ef6ad5b
commit e2eb7327c2
4 changed files with 29 additions and 0 deletions

View file

@ -95,6 +95,11 @@ class Point {
}
insert(entry) {
if (entry.key == null) throw new Error('entry.key must not be null');
if (this._skipList.containsKey(entry.key)) {
throw new Error(`an entry with key ${entry.key} already exists`);
}
const newNode = new Node(entry);
const pNodes = this.nodes;
const pIdxs = this.idxs;