UNPKG

710 BJavaScriptView Raw
1export class SkipListNode {
2 constructor(item = null) {
3 this.item = item;
4 this.next = [];
5 this.prev = [];
6 }
7 getItem() {
8 return this.item;
9 }
10 getNext(level) {
11 return this.next[level];
12 }
13 setNext(level, node) {
14 this.next[level] = node;
15 }
16 getPrev(level) {
17 return this.prev[level];
18 }
19 setPrev(level, node) {
20 this.prev[level] = node;
21 }
22 deleteLastLevel() {
23 this.next.length--;
24 }
25 getNextLevel() {
26 return this.next.length;
27 }
28 getPrevLevel() {
29 return this.prev.length;
30 }
31 getHeight() {
32 return Math.max(this.getPrevLevel(), this.getNextLevel());
33 }
34}