Skip to content

Commit

Permalink
Bump version to 1.8.0 and change signatures of nextHigherKey thru nex…
Browse files Browse the repository at this point in the history
…tLowerPair
  • Loading branch information
qwertie committed Mar 24, 2022
1 parent 1a2a9f6 commit e54ffd3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
20 changes: 12 additions & 8 deletions interfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ export interface ISortedSetSource<K=any> extends ISetSource<K>
minKey(): K | undefined;
/** Gets the highest key in the collection. */
maxKey(): K | undefined;
/** Returns the next key larger than the specified key (or undefined if there is none) */
nextHigherKey(key: K): K|undefined;
/** Returns the next key smaller than the specified key (or undefined if there is none) */
nextLowerKey(key: K): K|undefined;
/** Returns the next key larger than the specified key (or undefined if there is none).
* Also, nextHigherKey(undefined) returns the lowest key. */
nextHigherKey(key?: K): K|undefined;
/** Returns the next key smaller than the specified key (or undefined if there is none).
* Also, nextLowerKey(undefined) returns the highest key. */
nextLowerKey(key?: K): K|undefined;
/** Calls `callback` on the specified range of keys, in ascending order by key.
* @param low The first key scanned will be greater than or equal to `low`.
* @param high Scanning stops when a key larger than this is reached.
Expand All @@ -109,10 +111,12 @@ export interface ISortedSetSource<K=any> extends ISetSource<K>
/** An data source that provides read-only access to items in sorted order. */
export interface ISortedMapSource<K=any, V=any> extends IMapSource<K, V>, ISortedSetSource<K>
{
/** Returns the next pair whose key is larger than the specified key (or undefined if there is none) */
nextHigherPair(key: K): [K,V]|undefined;
/** Returns the next pair whose key is smaller than the specified key (or undefined if there is none) */
nextLowerPair(key: K): [K,V]|undefined;
/** Returns the next pair whose key is larger than the specified key (or undefined
* if there is none). If key === undefined, this function returns the lowest pair. */
nextHigherPair(key?: K): [K,V]|undefined;
/** Returns the next pair whose key is smaller than the specified key (or undefined
* if there is none). If key === undefined, this function returns the highest pair. */
nextLowerPair(key?: K): [K,V]|undefined;
/** Builds an array of pairs from the specified range of keys, sorted by key.
* Each returned pair is also an array: pair[0] is the key, pair[1] is the value.
* @param low The first key in the array will be greater than or equal to `low`.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sorted-btree",
"version": "1.7.0",
"version": "1.8.0",
"description": "A sorted list of key-value pairs in a fast, typed in-memory B+ tree with a powerful API.",
"main": "b+tree.js",
"typings": "b+tree",
Expand Down
21 changes: 16 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ This is a fast B+ tree implementation, largely compatible with the standard Map,

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

Ukraine
-------
Ukraine is still under attack
-----------------------------

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

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

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

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

Here you can see the famous theatre labeled "Children" in huge letters, which Russia bombed anyway.
Here you can see the famous Donetsk Academic Regional Drama Theatre, labeled "дети" ("children") in huge letters, which held over 1,000 civilians. Russia bombed it anyway.

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

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

Features
--------
Expand Down Expand Up @@ -418,6 +418,17 @@ Benchmarks (in milliseconds for integer keys/values)
Version history
---------------

### v1.8.0 ###

- Argument of `ISortedSetSource.nextHigherKey(key: K)` changed to `key?: K`
- Argument of `ISortedSetSource.nextLowerKey(key: K)` changed to `key?: K`
- Argument of `ISortedMapSource.nextHigherPair(key: K)` changed to `key?: K`
- Argument of `ISortedMapSource.nextLowerPair(key: K)` changed to `key?: K`

### v1.7.0 ###

- Added `asSet` method, defined as follows: `asSet<K,V>(btree: BTree<K,V>): undefined extends V ? ISortedSet<K> : unknown { return btree as any; }`

### v1.6.2 ###

- 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.
Expand Down

0 comments on commit e54ffd3

Please sign in to comment.