lkml.org 
[lkml]   [2009]   [Jan]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC] B+Tree library V2
From
Date
On Thu, 2009-01-08 at 17:24 +0100, Jörn Engel wrote:

> If you want to open-code it, you can use btree_lookup_less(). I added
> that function sometime last month. Basically something like this:
> key = btree_last(head, geo);
> while (key) {
> /* do something with key */
> key = btree_lookup_less(head, geo, key);
> }

Ok, so looking deeper into this, how about adding

#define btree_for_each_key(head, geo, key, tmp) \
for (key = btree_last(head, geo), tmp = btree_lookup_less(head, geo, key);
key; key = tmp, tmp = btree_lookup_less(head, geo, key))

(and possibly some type-checking variants that hardcode the geo)

Does that seem correct? And would it be possible to provide btree_last()
that takes an void ** and fills it with the last entry, and the same for
lookup_less(), so we can write btree_for_each_entry() too?

johannes
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2009-01-08 18:13    [W:0.410 / U:0.736 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site