Messages in this thread | | | Subject | Re: [RFC] B+Tree library V2 | From | Johannes Berg <> | Date | Thu, 08 Jan 2009 18:10:01 +0100 |
| |
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] | |