[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1231434601.8398.9.camel@johannes>
Date: Thu, 08 Jan 2009 18:10:01 +0100
From: Johannes Berg <johannes@...solutions.net>
To: Jörn Engel <joern@...fs.org>
Cc: linux-kernel@...r.kernel.org
Subject: Re: [RFC] B+Tree library V2
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
Download attachment "signature.asc" of type "application/pgp-signature" (837 bytes)
Powered by blists - more mailing lists