On Tuesday, 8 March 2016 at 08:12:04 UTC, Nordlöw wrote:
Has anybody put together a memory-efficient D-implementation of
a HashSet
Something like
sparse_hash_set<> contained in
https://github.com/sparsehash/sparsehash
but in D.
There is an implementation in:
code.dlang.org/packages/emsi_containers
But to be honest I got stuck trying to use it (copy constructor
disabled), so I used this very minimal wrapper around associative
array:
private struct HashSet(E) {
// TODO switch to proper implementation (not using AA)
bool put( E el )
{
if ( el in set )
return false;
set[el] = set.length;
return true;
}
size_t[E] set;
}
(I only needed put, since I used it to check whether we already
encountered a value before in a lazy/non sorted implementation of
uniq)