A case for valueless AA's?
Piotr Szturmaj
bncrbme at jadamspam.pl
Tue Mar 29 14:37:45 PDT 2011
Andrej Mitrovic wrote:
> 1. I'm wasting memory. I don't need the values, I only need the keys. But I can't declare a void[string] hash.
> But I don't know how to get rid of the values, which leaves the issue #1.
Maybe static array of zero length? From documentation:
"A static array with a dimension of 0 is allowed, but no space is
allocated for it. It's useful as the last member of a variable length
struct, or as the degenerate case of a template expansion."
And this code works:
void[0][string] aa;
aa["key"] = [];
assert("key" in aa);
But anyway, I feel that dedicated HashSet container would be more
appropriate.
More information about the Digitalmars-d
mailing list