R
Rasmus Villemoes
Hi
In a program I'm writing, I will need to access the 53130 different
5-element subsets of 0..24 many many times. So I thought I would
generate each of these subsets once and for all, using a canonical
enumeration scheme, and save the result in a global hash or array
(Concretely, I have generated a file containing lines of the form
"0:0,1,2,3,4", "1:0,1,2,3,5" etc., which I then read and parse at the
start of the program, that is, I generate an anonymous array
[0,1,2,3,4], and then I store a reference to this in $combs{0} or
$combs[0].)
Now the question is, should I store these in an array or a hash,
if I want to access a random entry as fast as possible?
In a program I'm writing, I will need to access the 53130 different
5-element subsets of 0..24 many many times. So I thought I would
generate each of these subsets once and for all, using a canonical
enumeration scheme, and save the result in a global hash or array
(Concretely, I have generated a file containing lines of the form
"0:0,1,2,3,4", "1:0,1,2,3,5" etc., which I then read and parse at the
start of the program, that is, I generate an anonymous array
[0,1,2,3,4], and then I store a reference to this in $combs{0} or
$combs[0].)
Now the question is, should I store these in an array or a hash,
if I want to access a random entry as fast as possible?