Gael Pegliasco wrote:
> > First is the choice of arrays verses hashes as the choice for set
storage.
> > Arrays are obviously easier to construct, but hashes are both faster
> > implementations, and easier to determine membership.
>
> Well in fact I'm interested by such functions in order to manipulate
> lists
> of scalars (1, 'toto') and to manipulate lists of hash table references
> ( { name => 'joe', age => 21 }, { name => 'sam', age => 27 } )
>
> and I'd like to use these functions independantly of the array content
> type.
>
The point is that a hash of booleans (not a list of hashes) is a more direct
way to implement a set. A set is unordered, and does not have duplicates.
This is also true of hash keys. Furthermore, the nature of a hash makes it
faster and easier to check for the existance of a key, which is the
fundamental operation of a set (test for membership).


Reply via email to