[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Old Timers ??



"J.D. Smith" wrote:
> 
> Eric Kihn wrote:

> > 2) It's clear this code is simulating a HASH with Arrays, does IDL 5.3 have
> > native hash support of some kind?
> 
> 2) No, sadly.  The get_keyword routine probably does a linear search
> through the header line array, looking for "file ID" in this case.  This
> is of course just the type of thing hashes were made for.  The
> get_keyword routine I found just uses "where", as you might expect.
> This means not only is the search linear, all elements are considered,
> even after a match is found.  It could have been made more efficient in
> IDL 5.4 if array_equal() had been implemented not just to return true as
> soon as a match is found, but return the index of that match.  Oh well.
> Maybe an optional variable will be added to array_equal for this in
> 5.4.1.  (hint)
> 
> It is possible to make a better simulation of a hash with a structure,
> but that is somewhat inflexible since adding new keywords (fields) is
> difficult, without copying the whole thing, though create_struct() can
> do it.  Then there is the matter of indexing the structure with a
> variable field (the essence of what hashes do).  Possible, but not
> efficient... in fact nearly as inefficient as a "where" on the full
> array.  Unfortunately, it's not that easy to write a good hash type that
> scales well for small and large hashes, and doesn't eat too much
> memory.

O.k., following the advice that "he who asks a question is a fool for 5 minutes, he who
does not ask a question is a fool forever" I have to ask:

What is a hash?

I have seen the term used before regarding string searches but, being a mostly fortran
number crunchy type programmer, I've never been one for searching through strings and what
not.

The only dictionary definitions I found were:
1) To chop up meat/potatoes into small pieces
2) To confuse or muddle
3) To stick in one's pipe and smoke it.

:o)

paulv

-- 
Paul van Delst           Ph:  (301) 763-8000 x7274
CIMSS @ NOAA/NCEP        Fax: (301) 763-8545
Rm.207, 5200 Auth Rd.    Email: pvandelst@ncep.noaa.gov
Camp Springs MD 20746