splaytree 3.1.2 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/splaytree.js +344 -0
- package/dist/splaytree.js.map +1 -0
- package/dist/splaytree.umd.cjs +3 -0
- package/dist/splaytree.umd.cjs.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/package.json +33 -62
- package/src/index.ts +197 -192
- package/dist/splay.esm.js +0 -686
- package/dist/splay.esm.js.map +0 -1
- package/dist/splay.js +0 -694
- package/dist/splay.js.map +0 -1
- package/typings/index.d.ts +0 -82
- package/typings/node.d.ts +0 -8
- package/typings/types.d.ts +0 -2
package/typings/index.d.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import Node from './node';
|
|
2
|
-
import { Key } from './types';
|
|
3
|
-
export declare type Comparator<Key> = (a: Key, b: Key) => number;
|
|
4
|
-
export declare type Visitor<Key, Value> = (node: Node<Key, Value>) => void;
|
|
5
|
-
export declare type NodePrinter<Key, Value> = (node: Node<Key, Value>) => string;
|
|
6
|
-
declare function DEFAULT_COMPARE(a: Key, b: Key): number;
|
|
7
|
-
export default class Tree<Key = number, Value = any> {
|
|
8
|
-
private _comparator;
|
|
9
|
-
private _root;
|
|
10
|
-
private _size;
|
|
11
|
-
constructor(comparator?: typeof DEFAULT_COMPARE);
|
|
12
|
-
/**
|
|
13
|
-
* Inserts a key, allows duplicates
|
|
14
|
-
*/
|
|
15
|
-
insert(key: Key, data?: Value): Node<Key, Value>;
|
|
16
|
-
/**
|
|
17
|
-
* Adds a key, if it is not present in the tree
|
|
18
|
-
*/
|
|
19
|
-
add(key: Key, data?: Value): Node<Key, Value>;
|
|
20
|
-
/**
|
|
21
|
-
* @param {Key} key
|
|
22
|
-
* @return {Node|null}
|
|
23
|
-
*/
|
|
24
|
-
remove(key: Key): void;
|
|
25
|
-
/**
|
|
26
|
-
* Deletes i from the tree if it's there
|
|
27
|
-
*/
|
|
28
|
-
private _remove;
|
|
29
|
-
/**
|
|
30
|
-
* Removes and returns the node with smallest key
|
|
31
|
-
*/
|
|
32
|
-
pop(): {
|
|
33
|
-
key: Key;
|
|
34
|
-
data: Value;
|
|
35
|
-
} | null;
|
|
36
|
-
/**
|
|
37
|
-
* Find without splaying
|
|
38
|
-
*/
|
|
39
|
-
findStatic(key: Key): Node<Key, Value> | null;
|
|
40
|
-
find(key: Key): Node<Key, Value> | null;
|
|
41
|
-
contains(key: Key): boolean;
|
|
42
|
-
forEach(visitor: Visitor<Key, Value>, ctx?: any): Tree<Key, Value>;
|
|
43
|
-
/**
|
|
44
|
-
* Walk key range from `low` to `high`. Stops if `fn` returns a value.
|
|
45
|
-
*/
|
|
46
|
-
range(low: Key, high: Key, fn: Visitor<Key, Value>, ctx?: any): Tree<Key, Value>;
|
|
47
|
-
/**
|
|
48
|
-
* Returns array of keys
|
|
49
|
-
*/
|
|
50
|
-
keys(): Key[];
|
|
51
|
-
/**
|
|
52
|
-
* Returns array of all the data in the nodes
|
|
53
|
-
*/
|
|
54
|
-
values(): Value[];
|
|
55
|
-
min(): Key | null;
|
|
56
|
-
max(): Key | null;
|
|
57
|
-
minNode(t?: Node<Key, Value>): Node<Key, Value> | null;
|
|
58
|
-
maxNode(t?: Node<Key, Value>): Node<Key, Value> | null;
|
|
59
|
-
/**
|
|
60
|
-
* Returns node at given index
|
|
61
|
-
*/
|
|
62
|
-
at(index: number): Node<Key, Value> | null;
|
|
63
|
-
next(d: Node<Key, Value>): Node<Key, Value> | null;
|
|
64
|
-
prev(d: Node<Key, Value>): Node<Key, Value> | null;
|
|
65
|
-
clear(): Tree<Key, Value>;
|
|
66
|
-
toList(): Node<any, any>;
|
|
67
|
-
/**
|
|
68
|
-
* Bulk-load items. Both array have to be same size
|
|
69
|
-
*/
|
|
70
|
-
load(keys: Key[], values?: Value[], presort?: boolean): this;
|
|
71
|
-
isEmpty(): boolean;
|
|
72
|
-
readonly size: number;
|
|
73
|
-
readonly root: Node<Key, Value> | null;
|
|
74
|
-
toString(printNode?: NodePrinter<Key, Value>): string;
|
|
75
|
-
update(key: Key, newKey: Key, newData?: Value): void;
|
|
76
|
-
split(key: Key): {
|
|
77
|
-
left: Node<any, any>;
|
|
78
|
-
right: Node<any, any>;
|
|
79
|
-
};
|
|
80
|
-
[Symbol.iterator](): IterableIterator<Node<Key, Value>>;
|
|
81
|
-
}
|
|
82
|
-
export {};
|
package/typings/node.d.ts
DELETED
package/typings/types.d.ts
DELETED