forked from thi-ng/umbrella
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(associative): rename EquivMap/Set => ArrayMap/Set, export in…
…terfaces
- Loading branch information
1 parent
a769856
commit 8756027
Showing
12 changed files
with
119 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,51 @@ | ||
import { Predicate2, Comparator } from "@thi.ng/api/api"; | ||
|
||
export type Pair<K, V> = [K, V]; | ||
|
||
export const SEMAPHORE = Symbol("SEMAPHORE"); | ||
|
||
export interface ArrayMapOpts<K> { | ||
equiv: Predicate2<K>; | ||
} | ||
|
||
export interface ArraySetOpts<T> { | ||
equiv: Predicate2<T>; | ||
} | ||
|
||
/** | ||
* SortedMapOpts implementation config settings. | ||
*/ | ||
export interface SortedMapOpts<K> { | ||
/** | ||
* Key equivalence predicate. MUST return truthy result if given | ||
* keys are considered equal. | ||
* | ||
* Default: `@thi.ng/api/equiv` | ||
*/ | ||
equiv: Predicate2<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/api/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>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.