Re: avltree / genalloc

2018-04-13 Thread Olivier Brunel
> Then genalloc is indeed the right data structure from you, but > I don't have helpers to arbitrarily remove an object in the middle. > Note that if you don't need index stability, it's trivial, and O(1): > you can just overwrite the ith object with the (n-1)th, and decrement > the length. No

Re: avltree / genalloc

2018-04-12 Thread Laurent Bercot
Ok, so let me ask you this: I want to delete my avltree. That is, I'd like to remove all its nodes and be done with it, i.e. I need to free all memory associated with it. I guess avltree_free() is enough, no need to delete each node individually? Yes, avltree_free() is enough, because an

Re: avltree / genalloc

2018-04-12 Thread Olivier Brunel
Many thanks for the explaination/clarifications! > avltree_iter isn't meant to perform operations that modify the > structure > of the tree. It *may* work, but there's no guarantee it will - and > typically, if you modify the tree, later values for node height will > certainly be incorrect.

Re: avltree / genalloc

2018-04-12 Thread Laurent Bercot
- When using avltree_iter() we need to pass a avliterfunc_t_ref, which takes 3 arguments. If I understand correctly, first is the uint32_t index, then the tree's "internal" (unsigned int) index, and my pointer. "The uint32_t index" is confusing terminology, so to clarify, I call this number