@thi.ng/sorted-map 1.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Change Log
2
+
3
+ - **Last updated**: 2024-07-22T13:15:57Z
4
+ - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
+
6
+ All notable changes to this project will be documented in this file.
7
+ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelines.
8
+
9
+ **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
+ and/or version bumps of transitive dependencies.
11
+
12
+ ## [1.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/sorted-map@1.1.0) (2024-07-22)
13
+
14
+ #### 🚀 Features
15
+
16
+ - import as new pkg ([#486](https://github.com/thi-ng/umbrella/issues/486)) ([02602e8](https://github.com/thi-ng/umbrella/commit/02602e8))
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,218 @@
1
+ <!-- This file is generated - DO NOT EDIT! -->
2
+ <!-- Please see: https://github.com/thi-ng/umbrella/blob/develop/CONTRIBUTING.md#changes-to-readme-files -->
3
+ # ![@thi.ng/sorted-map](https://media.thi.ng/umbrella/banners-20230807/thing-sorted-map.svg?a2ee1fc6)
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@thi.ng/sorted-map.svg)](https://www.npmjs.com/package/@thi.ng/sorted-map)
6
+ ![npm downloads](https://img.shields.io/npm/dm/@thi.ng/sorted-map.svg)
7
+ [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
+
9
+ > [!NOTE]
10
+ > This is one of 198 standalone projects, maintained as part
11
+ > of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
12
+ > and anti-framework.
13
+ >
14
+ > 🚀 Please help me to work full-time on these projects by [sponsoring me on
15
+ > GitHub](https://github.com/sponsors/postspectacular). Thank you! ❤️
16
+
17
+ - [About](#about)
18
+ - [SortedMap](#sortedmap)
19
+ - [Ranged queries](#ranged-queries)
20
+ - [SortedSet](#sortedset)
21
+ - [Status](#status)
22
+ - [Related packages](#related-packages)
23
+ - [Installation](#installation)
24
+ - [Dependencies](#dependencies)
25
+ - [API](#api)
26
+ - [Basic usage](#basic-usage)
27
+ - [Authors](#authors)
28
+ - [License](#license)
29
+
30
+ ## About
31
+
32
+ Skiplist-based sorted map & set implementation.
33
+
34
+ This package contains functionality which was previously part of and has been
35
+ extracted from the [@thi.ng/associative](https://thi.ng/associative) package.
36
+
37
+ [Skiplist](https://en.wikipedia.org/wiki/Skip_list) based `SortedMap` &
38
+ `SortedSet` implementing the full ES6 Map/Set APIs and additional features:
39
+
40
+ - range query iterators (via `entries()`, `keys()`, `values()`)
41
+ - [`ICompare`](https://docs.thi.ng/umbrella/api/interfaces/ICompare.html),
42
+ [`ICopy`](https://docs.thi.ng/umbrella/api/interfaces/ICopy.html),
43
+ [`IEmpty`](https://docs.thi.ng/umbrella/api/interfaces/IEmpty.html) &
44
+ [`IEquiv`](https://docs.thi.ng/umbrella/api/interfaces/IEquiv.html)
45
+ implementations
46
+ - multiple value additions / updates / deletions via `.into()`, `.dissoc()` or
47
+ `.disj()`
48
+ - configurable key equality & comparison (incl. default implementations)
49
+ - getters w/ optional "not-found" default value
50
+
51
+ The native ES6 implementations use **object reference** identity to determine
52
+ key containment, but often it's **more practical and useful to use equivalent
53
+ value semantics** for this purpose, especially when keys are structured data
54
+ (arrays / objects).
55
+
56
+ **Note**: It's the user's responsibility to ensure the inserted keys are kept
57
+ immutable (even if technically they're not).
58
+
59
+ ### SortedMap
60
+
61
+ Alternative implementation of the ES6 Map API using a Skip list as
62
+ backing store and support for configurable key equality and sorting
63
+ semantics. Like with sets, uses @thi.ng/equiv & @thi.ng/compare by
64
+ default.
65
+
66
+ William Pugh's (creator of this data structure) description:
67
+
68
+ > "Skip lists are probabilistic data structures that have the same
69
+ asymptotic expected time bounds as balanced trees, are simpler, faster
70
+ and use less space."
71
+
72
+ Data structure description:
73
+
74
+ - ftp://ftp.cs.umd.edu/pub/skipLists/skiplists.pdf
75
+ - https://en.wikipedia.org/wiki/Skip_list
76
+
77
+ #### Ranged queries
78
+
79
+ ```ts
80
+ import { defSortedMap } from "@thi.ng/sorted-map";
81
+
82
+ map = defSortedMap([
83
+ ["c", 3], ["a", 1], ["d", 4], ["b", 2]
84
+ ]);
85
+ // SortedMap { 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4 }
86
+
87
+ // all entries
88
+ [...map.entries()]
89
+ // [ [ 'd', 4 ], [ 'c', 3 ], [ 'b', 2 ], [ 'a', 1 ] ]
90
+
91
+ // range query w/ given start key
92
+ // also works with `keys()` and `values()`
93
+ [...map.entries("c")]
94
+ // [ [ 'c', 3 ], [ 'd', 4 ] ]
95
+
96
+ // unknown start keys are ok
97
+ [...map.entries("cc")]
98
+ // [ [ 'd', 4 ] ]
99
+
100
+ // range query w/ given MAX key
101
+ [...map.entries("c", true)]
102
+ // [ [ 'a', 1 ], [ 'b', 2 ], [ 'c', 3 ] ]
103
+ ```
104
+
105
+ ### SortedSet
106
+
107
+ Sorted set implementation with standard ES6 Set API, customizable value
108
+ equality and comparison semantics and additional functionality:
109
+
110
+ - range queries (via `entries`, `keys`, `values`)
111
+ - multiple value addition/deletion via `into()` and `disj()`
112
+
113
+ Furthermore, this class implements the `ICopy`, `IEmpty`, `ICompare` and
114
+ `IEquiv` interfaces defined by `@thi.ng/api`. The latter two allow
115
+ instances to be used as keys themselves in other data types defined in
116
+ this (and other) package(s).
117
+
118
+ This set uses a `SortedMap` as backing store.
119
+
120
+ ## Status
121
+
122
+ **STABLE** - used in production
123
+
124
+ [Search or submit any issues for this package](https://github.com/thi-ng/umbrella/issues?q=%5Bsorted-map%5D+in%3Atitle)
125
+
126
+ ## Related packages
127
+
128
+ - [@thi.ng/associative](https://github.com/thi-ng/umbrella/tree/develop/packages/associative) - ES Map/Set-compatible implementations with customizable equality semantics & supporting operations
129
+
130
+ ## Installation
131
+
132
+ ```bash
133
+ yarn add @thi.ng/sorted-map
134
+ ```
135
+
136
+ ESM import:
137
+
138
+ ```ts
139
+ import * as sm from "@thi.ng/sorted-map";
140
+ ```
141
+
142
+ Browser ESM import:
143
+
144
+ ```html
145
+ <script type="module" src="https://esm.run/@thi.ng/sorted-map"></script>
146
+ ```
147
+
148
+ [JSDelivr documentation](https://www.jsdelivr.com/)
149
+
150
+ For Node.js REPL:
151
+
152
+ ```js
153
+ const sm = await import("@thi.ng/sorted-map");
154
+ ```
155
+
156
+ Package sizes (brotli'd, pre-treeshake): ESM: 1.71 KB
157
+
158
+ ## Dependencies
159
+
160
+ - [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/develop/packages/api)
161
+ - [@thi.ng/associative](https://github.com/thi-ng/umbrella/tree/develop/packages/associative)
162
+ - [@thi.ng/checks](https://github.com/thi-ng/umbrella/tree/develop/packages/checks)
163
+ - [@thi.ng/compare](https://github.com/thi-ng/umbrella/tree/develop/packages/compare)
164
+ - [@thi.ng/random](https://github.com/thi-ng/umbrella/tree/develop/packages/random)
165
+ - [@thi.ng/transducers](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers)
166
+
167
+ Note: @thi.ng/api is in _most_ cases a type-only import (not used at runtime)
168
+
169
+ ## API
170
+
171
+ [Generated API docs](https://docs.thi.ng/umbrella/sorted-map/)
172
+
173
+ ### Basic usage
174
+
175
+ ```ts
176
+ import { defSortedSet, defSortedMap } from "@thi.ng/sorted-map";
177
+
178
+ // define keys w/ equal values
179
+ const a = [1, 2];
180
+ const b = [1, 2];
181
+
182
+ const set = defSortedSet([a, [-1, 2], [-1, -2]]);
183
+ // SortedSet { [ -1, -2 ], [ -1, 2 ], [ 1, 2 ] }
184
+
185
+ // `b` was not added directly, but the set uses value equality
186
+ set.has(b);
187
+ // true
188
+
189
+ const map = defSortedMap([[a, "foo"], [[-1, -2], "bar"]]);
190
+ // SortedMap { [ -1, -2 ] => 'bar', [ 1, 2 ] => 'foo' }
191
+
192
+ // `b` was not added directly, but the set uses value equality
193
+ map.get(b);
194
+ // "foo"
195
+
196
+ // key lookup w/ default value
197
+ map.get([3, 4], "n/a");
198
+ // "n/a"
199
+ ```
200
+
201
+ ## Authors
202
+
203
+ - [Karsten Schmidt](https://thi.ng)
204
+
205
+ If this project contributes to an academic publication, please cite it as:
206
+
207
+ ```bibtex
208
+ @misc{thing-sorted-map,
209
+ title = "@thi.ng/sorted-map",
210
+ author = "Karsten Schmidt",
211
+ note = "https://thi.ng/sorted-map",
212
+ year = 2018
213
+ }
214
+ ```
215
+
216
+ ## License
217
+
218
+ &copy; 2018 - 2024 Karsten Schmidt // Apache License 2.0
package/api.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ import type { Comparator } from "@thi.ng/api";
2
+ import type { IRandom } from "@thi.ng/random";
3
+ /**
4
+ * SortedMapOpts implementation config settings.
5
+ */
6
+ export interface SortedMapOpts<K> {
7
+ /**
8
+ * Key comparison function. Must follow standard comparator contract and
9
+ * return:
10
+ * - negative if `a < b`
11
+ * - positive if `a > b`
12
+ * - `0` if `a == b`
13
+ *
14
+ * Note: The {@link SortedMap} implementation only uses `<` and `==` style
15
+ * comparisons.
16
+ *
17
+ * @defaultValue
18
+ * [`compare()`](https://docs.thi.ng/umbrella/compare/functions/compare.html)
19
+ */
20
+ compare: Comparator<K>;
21
+ /**
22
+ * Probability for a value to exist in any express lane of the
23
+ * underlying Skip List implementation.
24
+ *
25
+ * @defaultValue `1 / Math.E`
26
+ */
27
+ probability: number;
28
+ /**
29
+ * Random number generator for choosing new insertion levels. By default
30
+ * uses
31
+ * [`SYSTEM`](https://docs.thi.ng/umbrella/random/variables/SYSTEM.html)
32
+ * from thi.ng/random pkg.
33
+ */
34
+ rnd: IRandom;
35
+ }
36
+ export type SortedSetOpts<T> = SortedMapOpts<T>;
37
+ //# sourceMappingURL=api.d.ts.map
package/api.js ADDED
File without changes
package/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./api.js";
2
+ export * from "./sorted-map.js";
3
+ export * from "./sorted-set.js";
4
+ //# sourceMappingURL=index.d.ts.map
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./api.js";
2
+ export * from "./sorted-map.js";
3
+ export * from "./sorted-set.js";
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "@thi.ng/sorted-map",
3
+ "version": "1.1.0",
4
+ "description": "Skiplist-based sorted map & set implementation",
5
+ "type": "module",
6
+ "module": "./index.js",
7
+ "typings": "./index.d.ts",
8
+ "sideEffects": false,
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/thi-ng/umbrella.git"
12
+ },
13
+ "homepage": "https://thi.ng/sorted-map",
14
+ "funding": [
15
+ {
16
+ "type": "github",
17
+ "url": "https://github.com/sponsors/postspectacular"
18
+ },
19
+ {
20
+ "type": "patreon",
21
+ "url": "https://patreon.com/thing_umbrella"
22
+ }
23
+ ],
24
+ "author": "Karsten Schmidt (https://thi.ng)",
25
+ "license": "Apache-2.0",
26
+ "scripts": {
27
+ "build": "yarn build:esbuild && yarn build:decl",
28
+ "build:decl": "tsc --declaration --emitDeclarationOnly",
29
+ "build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
30
+ "clean": "bun ../../tools/src/clean-package.ts",
31
+ "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
32
+ "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
33
+ "doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
34
+ "pub": "yarn npm publish --access public",
35
+ "test": "bun test",
36
+ "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
+ },
38
+ "dependencies": {
39
+ "@thi.ng/api": "^8.11.7",
40
+ "@thi.ng/associative": "^7.0.0",
41
+ "@thi.ng/checks": "^3.6.9",
42
+ "@thi.ng/compare": "^2.3.10",
43
+ "@thi.ng/random": "^4.0.0",
44
+ "@thi.ng/transducers": "^9.0.11"
45
+ },
46
+ "devDependencies": {
47
+ "@microsoft/api-extractor": "^7.47.0",
48
+ "esbuild": "^0.23.0",
49
+ "typedoc": "^0.26.3",
50
+ "typescript": "^5.5.3"
51
+ },
52
+ "keywords": [
53
+ "datastructure",
54
+ "equality",
55
+ "iterator",
56
+ "keys",
57
+ "map",
58
+ "query",
59
+ "set",
60
+ "skiplist",
61
+ "sort",
62
+ "typescript"
63
+ ],
64
+ "publishConfig": {
65
+ "access": "public"
66
+ },
67
+ "browser": {
68
+ "process": false,
69
+ "setTimeout": false
70
+ },
71
+ "engines": {
72
+ "node": ">=18"
73
+ },
74
+ "files": [
75
+ "./*.js",
76
+ "./*.d.ts"
77
+ ],
78
+ "exports": {
79
+ ".": {
80
+ "default": "./index.js"
81
+ },
82
+ "./api": {
83
+ "default": "./api.js"
84
+ },
85
+ "./sorted-map": {
86
+ "default": "./sorted-map.js"
87
+ },
88
+ "./sorted-set": {
89
+ "default": "./sorted-set.js"
90
+ }
91
+ },
92
+ "thi.ng": {
93
+ "related": [
94
+ "associative"
95
+ ],
96
+ "year": 2018
97
+ },
98
+ "gitHead": "324d6b7dbf31558329e9fb6452e29b2f7db9c61a\n"
99
+ }
@@ -0,0 +1,115 @@
1
+ import type { Fn3, IObjectOf, Maybe, Pair } from "@thi.ng/api";
2
+ import type { Reduced, ReductionFn } from "@thi.ng/transducers";
3
+ import type { SortedMapOpts } from "./api.js";
4
+ /** @internal */
5
+ declare class Node<K, V> {
6
+ k?: K | undefined;
7
+ v?: V | undefined;
8
+ level: number;
9
+ next: Maybe<Node<K, V>>;
10
+ prev: Maybe<Node<K, V>>;
11
+ up: Maybe<Node<K, V>>;
12
+ down: Maybe<Node<K, V>>;
13
+ constructor(k?: K | undefined, v?: V | undefined, level?: number);
14
+ }
15
+ /**
16
+ * Sorted map implementation based on Skip List data structure. Supports any
17
+ * keys (other than `undefined`) which can be sorted via user-defined
18
+ * comparator, given as ctor option.
19
+ *
20
+ * @remarks
21
+ * v6.3.0 .set() & .delete() implementations rewritten, based on:
22
+ *
23
+ * - https://en.wikipedia.org/wiki/Skip_list
24
+ * - https://www.youtube.com/watch?v=kBwUoWpeH_Q (MIT courseware)
25
+ * - https://www.educba.com/skip-list-java/
26
+ */
27
+ export declare class SortedMap<K, V> extends Map<K, V> {
28
+ constructor(pairs?: Iterable<Pair<K, V>> | null, opts?: Partial<SortedMapOpts<K>>);
29
+ get size(): number;
30
+ get [Symbol.species](): typeof SortedMap;
31
+ [Symbol.iterator](): IterableIterator<Pair<K, V>>;
32
+ /**
33
+ * Yields iterator of sorted `[key, value]` pairs, optionally taking given
34
+ * `key` and `max` flag into account.
35
+ *
36
+ * @remarks
37
+ * If `key` is given and `max=false`, the key is used as minimum search key
38
+ * and the iterator will only yield pairs for which keys are `>=` given key.
39
+ * If `max=true`, the given is used as maximum and only yields pairs for
40
+ * which keys are `<=` given key.
41
+ *
42
+ * If **no** key is given, yields **all** pairs.
43
+ *
44
+ * @param key
45
+ * @param max
46
+ */
47
+ entries(key?: K, max?: boolean): IterableIterator<Pair<K, V>>;
48
+ /**
49
+ * Similar to {@link SortedMap.entries}, but only yield sequence of keys.
50
+ *
51
+ * @param key
52
+ * @param max
53
+ */
54
+ keys(key?: K, max?: boolean): IterableIterator<K>;
55
+ /**
56
+ * Similar to {@link SortedMap.entries}, but only yield sequence of values.
57
+ *
58
+ * @param key
59
+ * @param max
60
+ */
61
+ values(key?: K, max?: boolean): IterableIterator<V>;
62
+ clear(): void;
63
+ empty(): SortedMap<K, V>;
64
+ copy(): SortedMap<K, V>;
65
+ compare(o: Map<K, V>): number;
66
+ equiv(o: any): boolean;
67
+ first(): (V | (K & ({} | null)) | undefined)[] | undefined;
68
+ get(key: K, notFound?: V): Maybe<V>;
69
+ has(key: K): boolean;
70
+ set(key: K, val: V): this;
71
+ delete(key: K): boolean;
72
+ into(pairs: Iterable<Pair<K, V>>): this;
73
+ dissoc(keys: Iterable<K>): this;
74
+ /**
75
+ * The key & value args given the callback `fn` MUST be treated as
76
+ * readonly/immutable. This could be enforced via TS, but would
77
+ * break ES6 Map interface contract.
78
+ *
79
+ * @param fn -
80
+ * @param thisArg -
81
+ */
82
+ forEach(fn: Fn3<V, K, Map<K, V>, void>, thisArg?: any): void;
83
+ $reduce<R>(rfn: ReductionFn<Pair<K, V>, R>, acc: R | Reduced<R>): R | Reduced<R>;
84
+ opts(): SortedMapOpts<K>;
85
+ /**
86
+ * Inserts `b` as successor of `a` (in the same lane as `a`).
87
+ *
88
+ * @param a
89
+ * @param b
90
+ */
91
+ protected insertInLane(a: Node<K, V>, b: Node<K, V>): void;
92
+ /**
93
+ * Links lanes by connecting `a` and `b` vertically.
94
+ *
95
+ * @param a
96
+ * @param b
97
+ */
98
+ protected linkLanes(a: Node<K, V>, b: Node<K, V>): void;
99
+ /**
100
+ * Returns first node on lowest level. Unless the map is empty, this node
101
+ * will be the first data node (with the smallest key).
102
+ */
103
+ protected firstNode(): Node<K, V>;
104
+ /**
105
+ * Returns the first matching (or predecessor) node for given key (NOT
106
+ * necessarily at the lowest level).
107
+ *
108
+ * @param key
109
+ */
110
+ protected findNode(key: K): Node<K, V>;
111
+ }
112
+ export declare function defSortedMap<K, V>(pairs?: Iterable<Pair<K, V>> | null, opts?: Partial<SortedMapOpts<K>>): SortedMap<K, V>;
113
+ export declare function defSortedMap<V>(obj: IObjectOf<V>, opts?: Partial<SortedMapOpts<string>>): SortedMap<string, V>;
114
+ export {};
115
+ //# sourceMappingURL=sorted-map.d.ts.map
package/sorted-map.js ADDED
@@ -0,0 +1,324 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+ import { dissoc } from "@thi.ng/associative/dissoc";
12
+ import { __equivMap } from "@thi.ng/associative/internal/equiv";
13
+ import { __inspectable } from "@thi.ng/associative/internal/inspect";
14
+ import { into } from "@thi.ng/associative/into";
15
+ import { isPlainObject } from "@thi.ng/checks/is-plain-object";
16
+ import { compare } from "@thi.ng/compare/compare";
17
+ import { SYSTEM } from "@thi.ng/random/system";
18
+ import { map } from "@thi.ng/transducers/map";
19
+ import { isReduced } from "@thi.ng/transducers/reduced";
20
+ class Node {
21
+ constructor(k, v, level = 0) {
22
+ this.k = k;
23
+ this.v = v;
24
+ this.level = level;
25
+ }
26
+ next;
27
+ prev;
28
+ up;
29
+ down;
30
+ }
31
+ const __private = /* @__PURE__ */ new WeakMap();
32
+ let SortedMap = class extends Map {
33
+ constructor(pairs, opts = {}) {
34
+ super();
35
+ __private.set(this, {
36
+ head: new Node(),
37
+ cmp: opts.compare || compare,
38
+ rnd: opts.rnd || SYSTEM,
39
+ p: opts.probability || 1 / Math.E,
40
+ size: 0
41
+ });
42
+ if (pairs) {
43
+ this.into(pairs);
44
+ }
45
+ }
46
+ get size() {
47
+ return __private.get(this).size;
48
+ }
49
+ get [Symbol.species]() {
50
+ return SortedMap;
51
+ }
52
+ *[Symbol.iterator]() {
53
+ let node = this.firstNode();
54
+ while (node && node.k !== void 0) {
55
+ yield [node.k, node.v];
56
+ node = node.next;
57
+ }
58
+ }
59
+ /**
60
+ * Yields iterator of sorted `[key, value]` pairs, optionally taking given
61
+ * `key` and `max` flag into account.
62
+ *
63
+ * @remarks
64
+ * If `key` is given and `max=false`, the key is used as minimum search key
65
+ * and the iterator will only yield pairs for which keys are `>=` given key.
66
+ * If `max=true`, the given is used as maximum and only yields pairs for
67
+ * which keys are `<=` given key.
68
+ *
69
+ * If **no** key is given, yields **all** pairs.
70
+ *
71
+ * @param key
72
+ * @param max
73
+ */
74
+ *entries(key, max = false) {
75
+ if (key === void 0) {
76
+ yield* this;
77
+ return;
78
+ }
79
+ const { cmp, size } = __private.get(this);
80
+ if (!size) return;
81
+ if (max) {
82
+ let node = this.firstNode();
83
+ while (node && node.k !== void 0 && cmp(node.k, key) <= 0) {
84
+ yield [node.k, node.v];
85
+ node = node.next;
86
+ }
87
+ } else {
88
+ let node = this.firstNode();
89
+ while (node.down) node = node.down;
90
+ while (node) {
91
+ if (node.k !== void 0 && cmp(node.k, key) >= 0) {
92
+ yield [node.k, node.v];
93
+ }
94
+ node = node.next;
95
+ }
96
+ }
97
+ }
98
+ /**
99
+ * Similar to {@link SortedMap.entries}, but only yield sequence of keys.
100
+ *
101
+ * @param key
102
+ * @param max
103
+ */
104
+ keys(key, max = false) {
105
+ return map((p) => p[0], this.entries(key, max));
106
+ }
107
+ /**
108
+ * Similar to {@link SortedMap.entries}, but only yield sequence of values.
109
+ *
110
+ * @param key
111
+ * @param max
112
+ */
113
+ values(key, max = false) {
114
+ return map((p) => p[1], this.entries(key, max));
115
+ }
116
+ clear() {
117
+ const $this = __private.get(this);
118
+ $this.head = new Node();
119
+ $this.size = 0;
120
+ }
121
+ empty() {
122
+ return new SortedMap(null, this.opts());
123
+ }
124
+ copy() {
125
+ return new SortedMap(this, this.opts());
126
+ }
127
+ compare(o) {
128
+ const n = this.size;
129
+ const m = o.size;
130
+ if (n < m) return -1;
131
+ if (n > m) return 1;
132
+ const i = this.entries();
133
+ const j = o.entries();
134
+ let x, y;
135
+ let c;
136
+ while (x = i.next(), y = j.next(), !x.done && !y.done) {
137
+ if ((c = compare(x.value[0], y.value[0])) !== 0 || (c = compare(x.value[1], y.value[1])) !== 0) {
138
+ return c;
139
+ }
140
+ }
141
+ return 0;
142
+ }
143
+ equiv(o) {
144
+ return __equivMap(this, o);
145
+ }
146
+ first() {
147
+ const node = this.firstNode();
148
+ return node && node.k !== void 0 ? [node.k, node.v] : void 0;
149
+ }
150
+ get(key, notFound) {
151
+ const $this = __private.get(this);
152
+ const node = this.findNode(key);
153
+ return node.k !== void 0 && $this.cmp(node.k, key) === 0 ? node.v : notFound;
154
+ }
155
+ has(key) {
156
+ const { cmp } = __private.get(this);
157
+ const node = this.findNode(key);
158
+ return node.k !== void 0 && cmp(node.k, key) === 0;
159
+ }
160
+ set(key, val) {
161
+ const $this = __private.get(this);
162
+ const { cmp, p, rnd } = $this;
163
+ let node = this.findNode(key);
164
+ if (node.k !== void 0 && cmp(node.k, key) === 0) {
165
+ node.v = val;
166
+ while (node.down) {
167
+ node = node.down;
168
+ node.v = val;
169
+ }
170
+ return this;
171
+ }
172
+ let newNode = new Node(key, val, node.level);
173
+ this.insertInLane(node, newNode);
174
+ let currLevel = node.level;
175
+ let headLevel = $this.head.level;
176
+ while (rnd.probability(p)) {
177
+ if (currLevel >= headLevel) {
178
+ const newHead = new Node(
179
+ void 0,
180
+ void 0,
181
+ headLevel + 1
182
+ );
183
+ this.linkLanes(newHead, $this.head);
184
+ $this.head = newHead;
185
+ headLevel++;
186
+ }
187
+ while (!node.up) node = node.prev;
188
+ node = node.up;
189
+ const tmp = new Node(key, val, node.level);
190
+ this.insertInLane(node, tmp);
191
+ this.linkLanes(tmp, newNode);
192
+ newNode = tmp;
193
+ currLevel++;
194
+ }
195
+ $this.size++;
196
+ return this;
197
+ }
198
+ delete(key) {
199
+ const $this = __private.get(this);
200
+ let node = this.findNode(key);
201
+ if (node.k === void 0 || $this.cmp(node.k, key) !== 0) return false;
202
+ while (node.down) node = node.down;
203
+ let prev;
204
+ let next;
205
+ while (node) {
206
+ prev = node.prev;
207
+ next = node.next;
208
+ if (prev) prev.next = next;
209
+ if (next) next.prev = prev;
210
+ node = node.up;
211
+ }
212
+ while (!$this.head.next && $this.head.down) {
213
+ $this.head = $this.head.down;
214
+ $this.head.up = void 0;
215
+ }
216
+ $this.size--;
217
+ return true;
218
+ }
219
+ into(pairs) {
220
+ return into(this, pairs);
221
+ }
222
+ dissoc(keys) {
223
+ return dissoc(this, keys);
224
+ }
225
+ /**
226
+ * The key & value args given the callback `fn` MUST be treated as
227
+ * readonly/immutable. This could be enforced via TS, but would
228
+ * break ES6 Map interface contract.
229
+ *
230
+ * @param fn -
231
+ * @param thisArg -
232
+ */
233
+ forEach(fn, thisArg) {
234
+ for (let p of this) {
235
+ fn.call(thisArg, p[1], p[0], this);
236
+ }
237
+ }
238
+ $reduce(rfn, acc) {
239
+ let node = this.firstNode();
240
+ while (node && node.k !== void 0 && !isReduced(acc)) {
241
+ acc = rfn(acc, [node.k, node.v]);
242
+ node = node.next;
243
+ }
244
+ return acc;
245
+ }
246
+ opts() {
247
+ const $this = __private.get(this);
248
+ return {
249
+ compare: $this.cmp,
250
+ probability: $this.p,
251
+ rnd: $this.rnd
252
+ };
253
+ }
254
+ /**
255
+ * Inserts `b` as successor of `a` (in the same lane as `a`).
256
+ *
257
+ * @param a
258
+ * @param b
259
+ */
260
+ insertInLane(a, b) {
261
+ b.prev = a;
262
+ b.next = a.next;
263
+ if (a.next) a.next.prev = b;
264
+ a.next = b;
265
+ }
266
+ /**
267
+ * Links lanes by connecting `a` and `b` vertically.
268
+ *
269
+ * @param a
270
+ * @param b
271
+ */
272
+ linkLanes(a, b) {
273
+ a.down = b;
274
+ b.up = a;
275
+ }
276
+ /**
277
+ * Returns first node on lowest level. Unless the map is empty, this node
278
+ * will be the first data node (with the smallest key).
279
+ */
280
+ firstNode() {
281
+ const { head } = __private.get(this);
282
+ let node = head;
283
+ while (node.down) node = node.down;
284
+ while (node.prev) node = node.prev;
285
+ if (node.next) node = node.next;
286
+ return node;
287
+ }
288
+ /**
289
+ * Returns the first matching (or predecessor) node for given key (NOT
290
+ * necessarily at the lowest level).
291
+ *
292
+ * @param key
293
+ */
294
+ findNode(key) {
295
+ let { cmp, head } = __private.get(this);
296
+ let node = head;
297
+ let next;
298
+ let down;
299
+ let nodeKey;
300
+ while (true) {
301
+ next = node.next;
302
+ while (next && cmp(next.k, key) <= 0) {
303
+ node = next;
304
+ next = node.next;
305
+ }
306
+ nodeKey = node.k;
307
+ if (nodeKey !== void 0 && cmp(nodeKey, key) === 0) break;
308
+ down = node.down;
309
+ if (!down) break;
310
+ node = down;
311
+ }
312
+ return node;
313
+ }
314
+ };
315
+ SortedMap = __decorateClass([
316
+ __inspectable
317
+ ], SortedMap);
318
+ function defSortedMap(src, opts) {
319
+ return isPlainObject(src) ? new SortedMap(Object.entries(src), opts) : new SortedMap(src, opts);
320
+ }
321
+ export {
322
+ SortedMap,
323
+ defSortedMap
324
+ };
@@ -0,0 +1,59 @@
1
+ import type { Fn3, ICompare, Maybe, Pair } from "@thi.ng/api";
2
+ import type { IEquivSet } from "@thi.ng/associative";
3
+ import type { IReducible, Reduced, ReductionFn } from "@thi.ng/transducers";
4
+ import type { SortedSetOpts } from "./api.js";
5
+ /**
6
+ * Sorted set implementation with standard ES6 Set API, customizable value
7
+ * equality and comparison semantics and additional functionality:
8
+ *
9
+ * - range queries (via {@link SortedSet.entries}, {@link SortedSet.keys},
10
+ * {@link SortedSet.values})
11
+ * - multiple value addition/deletion via {@link SortedSet.into} and
12
+ * {@link SortedSet.disj}
13
+ *
14
+ * Furthermore, this class implements the
15
+ * [`ICopy`](https://docs.thi.ng/umbrella/api/interfaces/ICopy.html), IEmpty`,
16
+ * [`ICompare`](https://docs.thi.ng/umbrella/api/interfaces/ICompare.html) and
17
+ * [`IEquiv`](https://docs.thi.ng/umbrella/api/interfaces/IEquiv.html)
18
+ * interfaces defined by [`thi.ng/api`](https://thi.ng/api). The latter two
19
+ * allow instances to be used as keys themselves in other data types defined in
20
+ * this (and other) package(s).
21
+ *
22
+ * This set uses a {@link SortedMap} as backing store and therefore has the same
23
+ * resizing characteristics.
24
+ */
25
+ export declare class SortedSet<T> extends Set<T> implements IEquivSet<T>, ICompare<Set<T>>, IReducible<T, any> {
26
+ /**
27
+ * Creates new instance with optional given values and/or
28
+ * implementation options. The options are the same as used by
29
+ * {@link SortedMap}.
30
+ *
31
+ * @param values - input values
32
+ * @param opts - config options
33
+ */
34
+ constructor(values?: Iterable<T> | null, opts?: Partial<SortedSetOpts<T>>);
35
+ [Symbol.iterator](): IterableIterator<T>;
36
+ get [Symbol.species](): typeof SortedSet;
37
+ get [Symbol.toStringTag](): string;
38
+ get size(): number;
39
+ copy(): SortedSet<T>;
40
+ empty(): SortedSet<T>;
41
+ compare(o: Set<T>): number;
42
+ equiv(o: any): boolean;
43
+ $reduce<R>(rfn: ReductionFn<T, any>, acc: R | Reduced<R>): R | Reduced<R>;
44
+ entries(key?: T, max?: boolean): IterableIterator<Pair<T, T>>;
45
+ keys(key?: T, max?: boolean): IterableIterator<T>;
46
+ values(key?: T, max?: boolean): IterableIterator<T>;
47
+ add(key: T): this;
48
+ into(keys: Iterable<T>): this;
49
+ clear(): void;
50
+ first(): T;
51
+ delete(key: T): boolean;
52
+ disj(keys: Iterable<T>): this;
53
+ forEach(fn: Fn3<Readonly<T>, Readonly<T>, Set<T>, void>, thisArg?: any): void;
54
+ has(key: T): boolean;
55
+ get(key: T, notFound?: T): Maybe<T>;
56
+ opts(): SortedSetOpts<T>;
57
+ }
58
+ export declare const defSortedSet: <T>(vals?: Iterable<T> | null, opts?: Partial<SortedSetOpts<T>>) => SortedSet<T>;
59
+ //# sourceMappingURL=sorted-set.d.ts.map
package/sorted-set.js ADDED
@@ -0,0 +1,129 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+ import { dissoc } from "@thi.ng/associative/dissoc";
12
+ import { __equivSet } from "@thi.ng/associative/internal/equiv";
13
+ import { __inspectable } from "@thi.ng/associative/internal/inspect";
14
+ import { into } from "@thi.ng/associative/into";
15
+ import { compare } from "@thi.ng/compare/compare";
16
+ import { map } from "@thi.ng/transducers/map";
17
+ import { SortedMap } from "./sorted-map.js";
18
+ const __private = /* @__PURE__ */ new WeakMap();
19
+ let SortedSet = class extends Set {
20
+ /**
21
+ * Creates new instance with optional given values and/or
22
+ * implementation options. The options are the same as used by
23
+ * {@link SortedMap}.
24
+ *
25
+ * @param values - input values
26
+ * @param opts - config options
27
+ */
28
+ constructor(values, opts) {
29
+ super();
30
+ __private.set(
31
+ this,
32
+ new SortedMap(
33
+ values ? map((x) => [x, x], values) : null,
34
+ opts
35
+ )
36
+ );
37
+ }
38
+ [Symbol.iterator]() {
39
+ return this.keys();
40
+ }
41
+ get [Symbol.species]() {
42
+ return SortedSet;
43
+ }
44
+ get [Symbol.toStringTag]() {
45
+ return "SortedSet";
46
+ }
47
+ get size() {
48
+ return __private.get(this).size;
49
+ }
50
+ copy() {
51
+ return new SortedSet(this.keys(), this.opts());
52
+ }
53
+ empty() {
54
+ return new SortedSet(null, this.opts());
55
+ }
56
+ compare(o) {
57
+ const n = this.size;
58
+ const m = o.size;
59
+ if (n < m) return -1;
60
+ if (n > m) return 1;
61
+ const i = this.entries();
62
+ const j = o.entries();
63
+ let x, y;
64
+ let c;
65
+ while (x = i.next(), y = j.next(), !x.done && !y.done) {
66
+ if ((c = compare(x.value[0], y.value[0])) !== 0) {
67
+ return c;
68
+ }
69
+ }
70
+ return 0;
71
+ }
72
+ equiv(o) {
73
+ return __equivSet(this, o);
74
+ }
75
+ $reduce(rfn, acc) {
76
+ return __private.get(this).$reduce((_acc, x) => rfn(_acc, x[0]), acc);
77
+ }
78
+ entries(key, max = false) {
79
+ return __private.get(this).entries(key, max);
80
+ }
81
+ keys(key, max = false) {
82
+ return __private.get(this).keys(key, max);
83
+ }
84
+ values(key, max = false) {
85
+ return __private.get(this).values(key, max);
86
+ }
87
+ add(key) {
88
+ __private.get(this).set(key, key);
89
+ return this;
90
+ }
91
+ into(keys) {
92
+ return into(this, keys);
93
+ }
94
+ clear() {
95
+ __private.get(this).clear();
96
+ }
97
+ first() {
98
+ const first = __private.get(this).first();
99
+ return first ? first[0] : void 0;
100
+ }
101
+ delete(key) {
102
+ return __private.get(this).delete(key);
103
+ }
104
+ disj(keys) {
105
+ return dissoc(this, keys);
106
+ }
107
+ forEach(fn, thisArg) {
108
+ for (let p of this) {
109
+ fn.call(thisArg, p, p, this);
110
+ }
111
+ }
112
+ has(key) {
113
+ return __private.get(this).has(key);
114
+ }
115
+ get(key, notFound) {
116
+ return __private.get(this).get(key, notFound);
117
+ }
118
+ opts() {
119
+ return __private.get(this).opts();
120
+ }
121
+ };
122
+ SortedSet = __decorateClass([
123
+ __inspectable
124
+ ], SortedSet);
125
+ const defSortedSet = (vals, opts) => new SortedSet(vals, opts);
126
+ export {
127
+ SortedSet,
128
+ defSortedSet
129
+ };