Memory Efficient HashSet

thedeemon via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 10 02:39:32 PST 2016


On Wednesday, 9 March 2016 at 22:31:50 UTC, Nordlöw wrote:
> consumes 842.m MiB on my Ubuntu.

Here's mine:
https://bitbucket.org/infognition/robinhood/src
(you just need one file rbhash.d to use in your apps)

The following test takes ~130 MB and can take less with some 
tweaks in the settings:

import std.stdio, rbhash;

alias Set(T) = RHHash!(T, void);

void main() {
     auto set = new Set!uint;
     foreach(i; 0..10_000_000)
         set.add(i);

     writeln(set.contains(444));
     readln;
}

It's a GC-free Robin Hood hash table implementation with special 
treatment for void as value type, i.e. sets.


More information about the Digitalmars-d-learn mailing list