From 5ff29ee556fa5687621bf98b4a45e8ae56b31868 Mon Sep 17 00:00:00 2001 From: n8allan <3095770+n8allan@users.noreply.github.com> Date: Mon, 11 Mar 2024 17:50:38 -0600 Subject: [PATCH] Fixed issues with path after insert. Optimized insert. Bug w/ rebalance. --- docs/assets/search.js | 2 +- docs/classes/BTree.html | 57 ++++++++++++++++---------------- docs/classes/KeyBound.html | 4 +-- docs/classes/KeyRange.html | 4 +-- docs/classes/Path.html | 4 +-- docs/classes/PathBranch.html | 4 +-- docs/variables/NodeCapacity.html | 2 +- package.json | 2 +- src/b-tree.ts | 47 +++++++++++--------------- test/b-tree.branching.test.ts | 13 ++++++-- 10 files changed, 69 insertions(+), 70 deletions(-) diff --git a/docs/assets/search.js b/docs/assets/search.js index 9620ff5..baad80d 100644 --- a/docs/assets/search.js +++ b/docs/assets/search.js @@ -1 +1 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAACr2b227bSBKG36XnlnHcR0q+m8wBGGQwEyxm50YwAkZqOYRlUkvS3jEMv/uieRCrqCqSpoW9EmL+VdVdX/WBzc6LKPL/luJm8yLu02wnbrSKRJY8eHEj/sh3/qfkmGzT6llE4rE4iBvxlBRp8u3gy4/w8dX36uEgIrE9JGXpS3EjxGvUuZRqdfL56a/C+5OzVv6x/uuoDyv7dm3zrKyKx22VFyOefsAy4DUSx6TwWXVqDmjqtTKnOF+LPK/GInSC3ndV7j6k5YdjkT4llZ8f6ckXZZpno8F6zbvj3fvnX4v84ZesKp7HYg50S+I6a7XrO/q1ej6O8Uchrxr5BzXO7wo1k+nyNn8IVuMF00n+Hx1to12dlGM97JrWh1PXph9V+7QoRyu1E8wbBcj3IRl33T5f4Hkf/jTa6Pr5As93frTJzeMFfpNRt8lCr0WS3Y2WSidY4Dst/04O6Wiae8kS/1npi9GsnBQLvD8ed0nlfxz1DzSLIky1/6RY4P3BF+NkO8EC3zt/8FO5AZol1V5ufbZLs7vRogeiRb2YEwSpls0HP+WP2dSk0GkWRMj8P6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2igHRkZjtPX9gBu04lsNpEdSuvG6XZK6Gw8eJs/nKgbTGHMbG8mwXBRpsuNINpsOVygEsMdfa9rY8KAAwU0hupghXnIZDTIEuKo5IMDwbXgrUuOKQBMsqP1/owNJquKW1sT1b60D1Ga76znoJkqq4cTUkYUFO3ZjR9vRfA3tjMO1xEPF7hQMFE3MpGS7gDuTRcQyC0bf2kzfoHZhqHBvvDDpopeLK+mz0SpB+yWXydI/ovK0GjGTLpfNkf6jvQAFrwNFwY6OZ/wdbclDhkstuY3jsLyCBFIMisNz00f2vGhAWkJHcwtNdPhpWhAUVYTmsxGutA32NyWF1G4ljevSHNPPiZnP7+vo/SDLiUDI7AAA="; \ No newline at end of file +window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAACr2bW2/bxhLHv8ueV8bxXmnprelpgSJFGhRtXwQjoKW1Q1gmdUjarWH4uxfLizhDzZA0LZwnI+J/Lpzf7HK53LyIIv+7FOvNi7hPs51YaxWJLHnwYi2+5Dv/Y3JItmn1LCLxWOzFWjwlRZrc7H35EV6++F497EUktvukLH0p1kK8Rp1Lqa6OPj/9UXh/dNbKP9a/jvqwss9rm2dlVTxuq7wY8fQfLANeI3FICp9Vx3RAqpfKHON8K/K8GovQCXrfVbn7kJYfDkX6lFR+fqQnX5Rpno0G6zXvjnfvn38u8oefsqp4Hos50C2J66zVrr/Rb9XzYYw/CnnRyD+ocX4XKE3mlrf5Q7Aab5hO8v+40TbaxVE5doddan04dWn6UXWbFuVop3aCeaMA+d4n467b6ws834afRpOury/wfOdHU24uL/CbjLpNFnotkuxutFU6wQLfaflXsk9Hy9xLlvjPSl+MVuWoWOD98bBLKv/DqH+gWRRhKv+jYoH3B1+Mk+0EC3zv/N5P1QZolnR7ufXZLs3uRpseiBbdxZwgSLVsPvgxf8ymJoVOsyBC5v8Z9d5eX9JD+ZP/MuEdaBZEOBTp+EqqEyzM/uuUfyhaEKN9OH72z+WMB24rIx7xeeW3ld+9Ye6rfJEl+x/mtDAlXrLMIDP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vnpgw60kOFaqLE9edaB+hhuiJzcJQCpuF4fkrBgAnBspHznt8f/MNcbg2mPaxz8YuAAiJibKIcPcAfCOK7LgtFN+xEa3B1892HjnUAHba24gCejV4LyS678x5M9p7ka0N2G6+6j/b4+lQSsAUfDTeTN/D9YU4MSSa7DG8NDfyQIBAYTkOW6oPu/JiAsyFdy+XbHgYYdYUFHWA4r8V7qANiYHJHXkTikB79PMy/Wm+vX138B3VM0cUg6AAA="; \ No newline at end of file diff --git a/docs/classes/BTree.html b/docs/classes/BTree.html index b51556a..cf5d4fe 100644 --- a/docs/classes/BTree.html +++ b/docs/classes/BTree.html @@ -2,7 +2,7 @@ Allows for efficient storage and retrieval of data in a sorted manner.
Optional
keyFromEntry: ((entry) => TKey) = ...a function to extract the key from an entry. The default assumes the key is the entry itself.
Optional
compare: ((a, b) => -1 | 0 | 1) = ...a comparison function for keys. The default uses < and > operators.
-Private
_rootPrivate
_versionPrivate
Readonly
comparea comparison function for keys. The default uses < and > operators.
+Private
_rootPrivate
_versionPrivate
Readonly
comparea comparison function for keys. The default uses < and > operators.
Private
Readonly
keya function to extract the key from an entry. The default assumes the key is the entry itself.
+Private
Readonly
keya function to extract the key from an entry. The default assumes the key is the entry itself.
Private
branchProtected
comparePrivate
branchProtected
compareInvokes user-provided comperator to compare two keys. Inner-loop code, so this doesn't do backflips to iron out ES's idiosyncrasies (undefined quirks, infinity, nulls, etc.), but does ensure deterministic comparison. If you want to eak out more performance at the risk of corruption, you can override this method and omit the consistency check.
-Iterates backward starting from the path location (inclusive) to the end. +
Private
findPrivate
findPrivate
firstRetrieves the entry for the given key. +
Private
findPrivate
findComputed (not stored) count. Computes the sum using leaf-node lengths. O(n/af) where af is average fill.
+Computed (not stored) count. Computes the sum using leaf-node lengths. O(n/af) where af is average fill.
Private
getPrivate
getPrivate
getPrivate
indexPrivate
indexPrivate
getPrivate
getPrivate
getPrivate
indexPrivate
indexPrivate
internalPrivate
internalPrivate
internalPrivate
internalPrivate
internalPrivate
internalPrivate
internalPrivate
internalPrivate
leafInserts or updates depending on the existence of the given key, using callbacks to generate the new value.
+Private
internalPrivate
internalPrivate
internalPrivate
internalPrivate
internalPrivate
internalPrivate
internalPrivate
internalPrivate
leafInserts or updates depending on the existence of the given key, using callbacks to generate the new value.
path to new entry and whether an update or insert attempted. If getUpdated callback returns a row that is already present, the resulting path will not be on.
-Private
movePrivate
moveIterates based on the given range +
Private
movePrivate
movePrivate
rebalancePrivate
rebalancePrivate
rebalancePrivate
rebalanceUpdates the entry at the given path to the given value. Deletes and inserts if the key changes.
path to resulting entry and whether it was an update (as opposed to an insert). * on = true if update/insert succeeded. * wasUpdate = true if updated; false if inserted. @@ -106,7 +105,7 @@ * on = false if update/insert failed. * wasUpdate = true, given path is not on an entry * else newEntry's new key already present; returned path is "near" existing entry
-Private
updateGenerated using TypeDoc
The type of keys used for indexing the entries. This might be an element of TEntry, or TEntry itself.