== Quote from Andrej Mitrovic ([email protected])'s article > Here's a little benchmark of Associative Arrays and Dynamic Arrays. I'm > showing traversal and lookup speed. The `static this()` is used to create a random collection of words which get stored in the two arrays: > https://gist.github.com/893340 > Hash lookups are naturally very fast. So I am inclined to use hashes for some > of my code, but there's a few problems: > 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. > 2. AA literals are awkward to write if you don't need the values: > Aa = ["foo":0, "bar":0, "car":0, > "dar":0, "mar":0, "doo":0]; > So there's redundancy there. > Anyhow, would this be a good case for valueless AA's? Is that even possible?
They're called sets. In Java I think they're named HashSet and TreeSet. In Python they're just named Set. Like AAs, the common ways to implement them are via hashing and balanced binary trees. They are usually fleshed out with operations like union, intersection and difference. I'm not sure whether these belong in the core language as an extension of AAs but if not they definitely belong in std.container.
