I submitted my container library to code.dlang.org

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 3 13:35:18 PDT 2015


On 04/03/2015 06:11 PM, w0rp wrote:
> 
> Now, I am not the most fantastic Computer Science guy in the world, and
> I probably got a few things wrong. If anyone would like to look at my
> code and point out mistakes, please do. I will add any improvements
> suggested.

You should use triangular numbers and power of 2 bucket sizes instead of
quadratic numbers and prime sized buckets, because that guarantees full
utilisation of the buckets and a minimal period of the numbers.

The necessary loop is really trivial.

https://github.com/D-Programming-Language/dmd/blob/f234c39a0e633fc9a0b5474fe2def76be9a373ef/src/root/stringtable.c#L162

If you replace

    i = (i + j) & (tabledim - 1);

with this

    i = (i + 1) & (tabledim - 1);

you get linear probing btw.


More information about the Digitalmars-d mailing list