Skip to content

Commit 1f4fa31

Browse files
committed
Bump version to 1.8.0 and change signatures of nextHigherKey thru nextLowerPair
1 parent 1a2a9f6 commit 1f4fa31

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

Diff for: interfaces.d.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ export interface ISortedSetSource<K=any> extends ISetSource<K>
8484
minKey(): K | undefined;
8585
/** Gets the highest key in the collection. */
8686
maxKey(): K | undefined;
87-
/** Returns the next key larger than the specified key (or undefined if there is none) */
88-
nextHigherKey(key: K): K|undefined;
89-
/** Returns the next key smaller than the specified key (or undefined if there is none) */
90-
nextLowerKey(key: K): K|undefined;
87+
/** Returns the next key larger than the specified key (or undefined if there is none).
88+
* Also, nextHigherKey(undefined) returns the lowest key. */
89+
nextHigherKey(key?: K): K|undefined;
90+
/** Returns the next key smaller than the specified key (or undefined if there is none).
91+
* Also, nextLowerKey(undefined) returns the highest key. */
92+
nextLowerKey(key?: K): K|undefined;
9193
/** Calls `callback` on the specified range of keys, in ascending order by key.
9294
* @param low The first key scanned will be greater than or equal to `low`.
9395
* @param high Scanning stops when a key larger than this is reached.
@@ -109,10 +111,12 @@ export interface ISortedSetSource<K=any> extends ISetSource<K>
109111
/** An data source that provides read-only access to items in sorted order. */
110112
export interface ISortedMapSource<K=any, V=any> extends IMapSource<K, V>, ISortedSetSource<K>
111113
{
112-
/** Returns the next pair whose key is larger than the specified key (or undefined if there is none) */
113-
nextHigherPair(key: K): [K,V]|undefined;
114-
/** Returns the next pair whose key is smaller than the specified key (or undefined if there is none) */
115-
nextLowerPair(key: K): [K,V]|undefined;
114+
/** Returns the next pair whose key is larger than the specified key (or undefined
115+
* if there is none). If key === undefined, this function returns the lowest pair. */
116+
nextHigherPair(key?: K): [K,V]|undefined;
117+
/** Returns the next pair whose key is smaller than the specified key (or undefined
118+
* if there is none). If key === undefined, this function returns the highest pair. */
119+
nextLowerPair(key?: K): [K,V]|undefined;
116120
/** Builds an array of pairs from the specified range of keys, sorted by key.
117121
* Each returned pair is also an array: pair[0] is the key, pair[1] is the value.
118122
* @param low The first key in the array will be greater than or equal to `low`.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sorted-btree",
3-
"version": "1.7.0",
3+
"version": "1.8.0",
44
"description": "A sorted list of key-value pairs in a fast, typed in-memory B+ tree with a powerful API.",
55
"main": "b+tree.js",
66
"typings": "b+tree",

Diff for: readme.md

+16-5
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ This is a fast B+ tree implementation, largely compatible with the standard Map,
99

1010
Use `npm install sorted-btree` in a terminal to install it in your npm-based project.
1111

12-
Ukraine
13-
-------
12+
Ukraine is still under attack
13+
-----------------------------
1414

15-
I'm writing this on the one-month anniversary of the full-scale invasion of Ukraine.
15+
I'm writing this on March 24, 2022: the one-month anniversary of the full-scale invasion of Ukraine.
1616

1717
![Mariupol](http://david.loyc.net/misc/ukraine/Mariupol-from-above.webp)
1818

@@ -28,7 +28,7 @@ Without electricity, reports from Mariupol have been limited, but certainly ther
2828

2929
![Mariupol apartment bombed](http://david.loyc.net/misc/ukraine/Mariupol-explosion.webp)
3030

31-
Here you can see the famous theatre labeled "Children" in huge letters, which Russia bombed anyway.
31+
Here you can see the famous theatre labeled "дети" ("children") in huge letters, which held over 1,000 civilians. Russia bombed it anyway.
3232

3333
![Mariupol theatre](http://david.loyc.net/misc/ukraine/Mariupol-theatre-children.webp)
3434
![Mariupol theatre before](http://david.loyc.net/misc/ukraine/Mariupol-theatre-children-before.jpg)
@@ -48,7 +48,7 @@ Or in these other places...
4848
![Kharkiv](http://david.loyc.net/misc/ukraine/Kharkiv-firefighters-rubble.webp)
4949
![Kharkiv](http://david.loyc.net/misc/ukraine/Kharkiv-two-dead.webp)
5050

51-
What's that? You just wanted a B+ tree? Fair enough. I hope it meets your needs.
51+
What's that? You just wanted a B+ tree? Well, you're in for a treat.
5252

5353
Features
5454
--------
@@ -418,6 +418,17 @@ Benchmarks (in milliseconds for integer keys/values)
418418
Version history
419419
---------------
420420

421+
### v1.8.0 ###
422+
423+
- Argument of `ISortedSetSource.nextHigherKey(key: K)` changed to `key?: K`
424+
- Argument of `ISortedSetSource.nextLowerKey(key: K)` changed to `key?: K`
425+
- Argument of `ISortedMapSource.nextHigherPair(key: K)` changed to `key?: K`
426+
- Argument of `ISortedMapSource.nextLowerPair(key: K)` changed to `key?: K`
427+
428+
### v1.7.0 ###
429+
430+
- Added `asSet` method, defined as follows: `asSet<K,V>(btree: BTree<K,V>): undefined extends V ? ISortedSet<K> : unknown { return btree as any; }`
431+
421432
### v1.6.2 ###
422433

423434
- Bug fixes: two rare situations were discovered in which shared nodes could fail to be marked as shared, and as a result, mutations could affect copies that should have been completely separate.

0 commit comments

Comments
 (0)