Need a collection of unique elements (like C++ std::set).

Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com> Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com>
Wed Jan 1 17:21:18 PST 2014


On Wednesday, 1 January 2014 at 21:54:13 UTC, Cooler wrote:
> RedBlackTree can help me. But RedBlackTree uses O(log(n)) time 
> for insert/remove operations.

If that is too slow, maybe you could roll your own simple hash 
table with open addressing and set the entries to negative values 
rather than delete? If the values/access patterns/hash/table size 
is right you might get O(1) and no need for bounds checks on 
array indexing either.

I assume basic associative arrays will have a more costly/generic 
hash function and need to rehash the table a few times as it 
grows.


More information about the Digitalmars-d mailing list