durusmail: durus-users: counted btree
counted btree
2007-05-04
counted btree
Jesus Cea
2007-05-04
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Current durus btree implementation is indexed by key. So you can get the
smaller or the bigger key in the btree, or iterate the btree, just fine.

For an application I'm designing just now, I would need a "counted"
btree, just like explained in
http://www.chiark.greenend.org.uk/~sgtatham/algorithms/cbtree.html

This structure can retrieve the i-th element in the btree very easily,
without knowing its key. Also, "len()" would be very fast.

The only problem with this "cbtree" structure would be more objects
changes when modifying the tree and, *worse*, bigger conflict risk
because any change in the tree modifies all the tree path up to the root
object.

I'm thinking about coding a cbtree patch for durus, but I would like to
read any suggestion you could do to retrieve the i-th element in a btree
without "i" iterations. I'm able to iterate, if the iteration count is
small enough, nevertheless. For example, I could keep a second btree
indexed by count (every 100 "i's") to locate fast the 100's element
closer to the 'i' element requested, and then iterate from there to
retrieve the 'i-th' element. But index management when
inserting/deleting elements would be O(N/100/2) and object retrieval
would be O(100/2), with random values.

Suggestions very appreciated.

- --
Jesus Cea Avion                         _/_/      _/_/_/        _/_/_/
jcea@argo.es http://www.argo.es/~jcea/ _/_/    _/_/  _/_/    _/_/  _/_/
jabber / xmpp:jcea@jabber.org         _/_/    _/_/          _/_/_/_/_/
                               _/_/  _/_/    _/_/          _/_/  _/_/
"Things are not so easy"      _/_/  _/_/    _/_/  _/_/    _/_/  _/_/
"My name is Dump, Core Dump"   _/_/_/        _/_/_/      _/_/  _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQCVAwUBRjtVuJlgi5GaxT1NAQKNYgP/VSFKJ2+vrk/wtgnpiki0NQmax4eBEo+f
lAZaIeoacFc6L23K8OhfT4rC6w7hmxoW+PpGwZcHTxDHxp8kAudBA2I4X0YJ3Kau
3zqeyXSQLOKUxSy95b+xdc/vNIYMuqOx/xaswGeMwOlsmIikKvCSCiFmZ91tlG7F
hKlGofUpqB4=
=Z7FV
-----END PGP SIGNATURE-----
reply