avltree / genalloc

From: Olivier Brunel <jjk_at_jjacky.com>
Date: Thu, 12 Apr 2018 19:13:20 +0200

Hey,

So I've been using avltree & gensetdyn (amongst others) lately in a
little project of mine, and I have some questions:

- 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.

  So if I wanted, from there, to remove an item from the avltree, I
  could either use avltree_deletenode(tree, ARG2) or
  avltree_delete(tree, KEY) where KEY is the one from dtok(ARG1,p) --
  would all that be correct, or did I miss/misunderstood something?

- So it means avltree_deletenode() needs the avltree's own/internal
  index, whereas gensetdyn_delete() needs "our" uint32_t index,
  correct?
  I.e. if I have that uint32_t and want to remove things from both the
  avltree & gensetdyn (I'm using the later to store the actual data
  indexed via the former, btw) then for avltree I need to get the key
  (e.g. via t->dtok(u,p))

- I think there's a bug in skalibs right now, avltree_deletenode() is
  broken and things don't even compile; I believe the attached patch is
  a correct fix for it.
  (I ended up using avltree_delete directly, guessing you usually do
  that as well maybe?)


- And on a completely unrelated topic, is there really no way
  (macro/function) in skalibs to remove an item from a genalloc? I get
  it for stralloc, it's not really thought of as an array but a string,
  you rarely want to remove one char from somehere in the middle, whatever.

  But with a genalloc, I'd expect one to (often) be wanting to remove an
  item from the array, and not always/only the last one, yet I can't see
  how that's supposed to be done? (Again, as in via a macro or
  something, of course one can - as I do - handle the memmove oneself)

  Maybe I'm the odd one for wanting to do such a thing on a regular
  basis, but something like in the (other) attached patch, I feel,
  might be useful. I know it certainly wasn't the first time I have to
  write that sort of things...


Thanks for the help!

Cheers,



Received on Thu Apr 12 2018 - 17:13:20 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC