Add core:container/rbtree
Add a red-black tree with configurable $Key and $Value. Also includes tests that verify it maintains RB invariants, doesn't leak. Originally based on the CC0 implementation from literateprograms.org. But reworked to the same API used by @Yawning's excellent `core:container/avl` for ease of use.
This commit is contained in:
1 parent
7dc1f114b9
commit
410876b36a
6 files changed
+866
-60
No files matched your search
@@ -5,13 +5,10 @@ The implementation is non-intrusive, and non-recursive.
|
||||
*/
|
||||
package container_avl
|
||||
|
||||
import "base:intrinsics"
|
||||
import "base:runtime"
|
||||
@(require) import "base:intrinsics"
|
||||
@(require) import "base:runtime"
|
||||
import "core:slice"
|
||||
|
||||
_ :: intrinsics
|
||||
_ :: runtime
|
||||
|
||||
// Originally based on the CC0 implementation by Eric Biggers
|
||||
// See: https://github.com/ebiggers/avl_tree/
|
||||
|
||||
@@ -675,4 +672,4 @@ iterator_first :: proc "contextless" (it: ^Iterator($Value)) {
|
||||
if it._cur != nil {
|
||||
it._next = node_next_or_prev_in_order(it._cur, it._direction)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user