Amanieu / intrusive-rs

Intrusive collections for Rust
Apache License 2.0
400 stars 47 forks source link

intrusive RBLTree #77

Closed crusader-mike closed 1 year ago

crusader-mike commented 1 year ago

(For reasons outside of this question) I need to build an intrusive RB tree where:

Is it possible to do this with intrusive_collections::rbtree::RBTree?

Amanieu commented 1 year ago

Yes for points 2 and 3. However for point 1 that is not possible, You need a mutable reference to the RBTree itself to remove an element from it. Consider the case where this is the last element in the tree: you need to be able to update the RBTree itself to set its root node pointer to null.

crusader-mike commented 1 year ago

I am not sure about rbtree implementation, but in theory it shouldn't be a problem -- just like in case of a keyring (double-linked list with special null node) removing last element will simply make null node it's own neighbor...