-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjump-hash.d.ts
More file actions
34 lines (30 loc) · 845 Bytes
/
jump-hash.d.ts
File metadata and controls
34 lines (30 loc) · 845 Bytes
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
/**
* JumpConsistentHash maps string keys to an integer index in [0, N)
* using the Jump Consistent Hash algorithm by Lamping & Veach.
*/
declare class JumpConsistentHash {
/**
* Create a new JumpConsistentHash instance.
*
* @param indexes - Total number of indexes (buckets), must be a positive integer.
*/
constructor(indexes: number);
/**
* Update number of indexes (buckets).
*
* @param indexes - Positive integer number of buckets.
*/
setIndexes(indexes: number): void;
/**
* Get current number of indexes (buckets).
*/
size(): number;
/**
* Compute stable index in [0, indexes) for the given key.
*
* @param key - Non-empty string key.
* @returns Index between 0 (inclusive) and indexes (exclusive).
*/
getIndex(key: string): number;
}
export default JumpConsistentHash;