I need to implement a "persistent" set. That is, a data structure that only supports a membership test. In addition (of course), I need a factory procedure, which, given the list of elements, builds a constant set.
Please note that not only the mutation is not allowed for a set of constants, but in addition I do not need the “add” operation, which returns a new set of constants (that is, after initialization, I'm only interested in testing if there is an element in the set or not).
The old Goold hash tables are the obvious choice here, but I wonder if we can somehow take advantage of the fact that we only need to support one operation (and, when building the set, we know that all its elements will be)? Is there a data structure (a specialized type of hash table, perhaps) that will work especially well here?
abeln source
share