Foo JH <[EMAIL PROTECTED]>, on 20 Nov 2008 10:40:13 +0800 wrote:
> Fish, David wrote:
> > Hello! The problem I am having is I am pulling data from a table in a
> > certain order and loading it into the hash array but when I read the
> > hash array it comes out in a different order than it is written. What
I
[..]
> Wouldn't a stack (essentially just an array) be better than a hash?
Not necessarily. A hash is a good solution if there is an issue with
de-duping.
If there is no de-duping, then pushing into a stack, and "foreach"ing the
values after they have all been entered is probably best. However, you
might be able to avoid the storage, by doing whatever you were going to do
as you read them instead of reading them all in at once and then
processing.
If there is de-duping, then hashes make a lot of sense. If you were going
to do all the processing at the end, push them into the hash, and add a
integer that is incremented on first insert, then finally run over the
stack sorting on that integer key. But again, if you can process them as
you read them, read the item, see if its in the hash, and if not then
insert it and process it.
--woody
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs