-
-
Notifications
You must be signed in to change notification settings - Fork 150
/
api.ts
73 lines (66 loc) · 1.69 KB
/
api.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import {
Comparator,
ICopy,
IEmpty,
IEquiv,
Predicate2
} from "@thi.ng/api";
export interface IEquivSet<T> extends
Set<T>,
ICopy<IEquivSet<T>>,
IEmpty<IEquivSet<T>>,
IEquiv {
readonly [Symbol.species]: EquivSetConstructor;
into(xs: Iterable<T>): this;
disj(xs: Iterable<T>): this;
get(val: T, notFound?: any): any;
first(): T;
opts(): EquivSetOpts<T>;
}
export interface EquivSetConstructor {
new(): IEquivSet<any>;
new <T>(values?: Iterable<T>, opts?: EquivSetOpts<T>): IEquivSet<T>;
readonly prototype: IEquivSet<any>;
}
export interface EquivSetOpts<T> {
/**
* Key equivalence predicate. MUST return truthy result if given
* keys are considered equal.
*
* Default: `@thi.ng/equiv`
*/
equiv: Predicate2<T>;
}
export interface EquivMapOpts<K> extends EquivSetOpts<K> {
keys: EquivSetConstructor;
}
/**
* SortedMapOpts implementation config settings.
*/
export interface SortedMapOpts<K> extends EquivSetOpts<K> {
/**
* Key comparison function. Must follow standard comparator contract
* and return:
* - negative if `a < b`
* - positive if `a > b`
* - `0` if `a == b`
*
* Note: The `SortedMap` implementation only uses `<` comparisons.
*
* Default: `@thi.ng/compare`
*/
compare: Comparator<K>;
/**
* Initial capacity before resizing (doubling) occurs.
* This value will be rounded up to next pow2.
*
* Default: 16
*/
capacity: number;
/**
* Probability for a value to exist in any express lane.
* Default: `1 / Math.E`
*/
probability: number;
}
export type SortedSetOpts<T> = SortedMapOpts<T>;