Erlang/OTP Forums

Author Message

<  Erlang questions mailing list  ~  rbdict - A dictionary as a Red-Black tree

rvirding
Posted: Sun Jun 15, 2008 10:49 am Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
I have just released rbdict, a dictionary as a Red-Black tree.

This is a dict compatible dictionary based on Red-Black trees. It supports the full dict interface and is drop-in compatible with both dict and orddict. Documentation is included.

There is also an alternate implementation, in rbdict1, which is a little slower but is included as another example of working on red-black trees. These are tricky little bastards so it is helpful to see other implementations.

It is down-loadable from trapext.org:

http://forum.trapexit.org/viewtopic.php?p=43948#43948

It would be good to see how it fares under the same unit tests as dict, and orddict. Hint, hint!


Post received from mailinglist
View user's profile Send private message Visit poster's website MSN Messenger
Guest
Posted: Mon Jun 16, 2008 4:14 pm Reply with quote
Guest
I ran the following code thru fprof using N=1000 for Mod=dict and Mod=rbdict. The basic results were that rbdict was ~10-20ms slower than dict for both store and fetch.

store(Mod, N) ->
rvirding
Posted: Mon Jun 16, 2008 7:46 pm Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
2008/6/16 Jacob Perkins <japerk@gmail.com (japerk@gmail.com)>:
Quote:
I ran the following code thru fprof using N=1000 for Mod=dict and Mod=rbdict. The basic results were that rbdict was ~10-20ms slower than dict for both store and fetch.

store(Mod, N) ->
View user's profile Send private message Visit poster's website MSN Messenger
rvirding
Posted: Mon Jun 16, 2008 8:54 pm Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
2008/6/16 Robert Virding <rvirding@gmail.com (rvirding@gmail.com)>:
Quote:

This is expected, rb-trees are O(n lg n) but dict is based on a hashing algorithm as is almost O(1).


I made a mistake here as Fuad pointed out to me, rb-trees are of course O(lg n).

Robert




Post received from mailinglist
View user's profile Send private message Visit poster's website MSN Messenger

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum