#10 Iterating over each element

open
nobody
None
5
2004-12-20
2004-12-20
Anonymous
No

It would be nice if there was a way to iterate over each key/value
pair in a JudyHS Array.
A interface for iterating over each value/Word_t (in an arbitrary
order) would also be useful (in JudyL, JudySL and JudyHS) -
especially for use in systems that do mark and sweep garbage
collection.

Thanks for Judy!

Discussion

  • Nobody/Anonymous

    Logged In: NO

    By arbitrary order, I mean any order (probably the most efficient order)
    so long as each element (Word_t *pValue) is reached.
    This way systems that do mark and sweep garbage collection could
    quickly mark each element.

     
  • Nobody/Anonymous

    Logged In: NO

    iterators can be easily built from the exiting
    functionality, however, you only have a choice of the order
    given. I think adding additional indexes would slow down
    the system and make it consume more memory. You can always
    resort the array or use a simple insertion-sort into another
    judy array if you wish to temporarily index on something else.

    I'm not clear on how iterators and garbage collectors
    relate. I would like to see some sort of pluggable memory
    management to make garbage collectors easier to integrate,
    however, if you are using boehm's GC, I believe that the
    -DREDIRECT_MALLOC option would be effective. If would be
    simple enough to test - add a bunch of data to a Judy array
    and then copy it to another one without freeing the first in
    a tight a loop with GC_PRINT_STATS turned on - see if the
    memory use evens out or grows forever.

     
  • James Murphy

    James Murphy - 2008-06-18

    Logged In: YES
    user_id=2121476
    Originator: NO

    Hi,

    I too was pretty disappointed when I found out I could not iterate over the JudyHS array in ANY order. In my array I have a collection of objects. The objects are referred to by a parent. When the parent is deleted I want to delete all the members of the collection. I don't know their indexes and lengths up front so I can't delete them by looking them up first.

    Yes, I could create a parallel JudyL array whose index was a the pointer to the other object, but that seems like a waste of time and memory.

    Thanks,

    Jim

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks