motoko-base icon indicating copy to clipboard operation
motoko-base copied to clipboard

Possible improvements for `RBTree`

Open luc-blaeser opened this issue 2 years ago • 5 comments

Possible improvements for RBTree:

  • Reduce garbage creation, especially during reading functions, such as get() and iteration.
  • More efficient size() function.

luc-blaeser avatar Jan 05 '23 09:01 luc-blaeser

Another long-standing issue with RBTree is that it does not fully support delete.

Separately but also related, RBTree is purely functional. So maybe some users would consider an additional imperative version to be another dimension of improvement?

matthewhammer avatar Jan 11 '23 16:01 matthewhammer

We should probably round out the functional one before adding an imperative one. Ie implement purely functional delete. Is it hard? Genuine question.

crusso avatar Jan 11 '23 18:01 crusso

(Sorry, didn't mean to reference this issue from irrelevant PR #500 - meant #499)

crusso avatar Jan 13 '23 14:01 crusso

Reduce garbage creation, especially during reading functions, such as get() and iteration

General question: How can get() produce garbage? It's only reading. Recursion builds up the stack but that isn't garbage. What am I missing?

timohanke avatar Mar 01 '23 07:03 timohanke

Separately but also related, RBTree is purely functional. So maybe some users would consider an additional imperative version to be another dimension of improvement?

I wonder what kind of improvement we can expect from an imperative one. Wouldn't it end up looking very similar and have the same representation? What would get improved?

timohanke avatar Mar 01 '23 07:03 timohanke