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

Cooler kulkin at hotbox.ru
Thu Jan 2 02:57:22 PST 2014


On Thursday, 2 January 2014 at 01:21:19 UTC, Ola Fosheim Grøstad 
wrote:
> 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.

My point is to don't invent something new. Such fundamental 
collection must exist at basic.


More information about the Digitalmars-d mailing list