IMO all of the dictionary routines in the standard runtime are
sub-optimal. It's either RYO, use open source libraries of which there
are many excellent examples or, if you are feeling brave, use C++ and
take advantage of the STL.
On 29/05/2013 10:48 AM, Paul Gilmartin wrote:
In the C/C++ RTL manual; hsearch(); 3.434.3 General description; I see:
Threading Behavior: The hcreate() function allocates a piece of storage for use
as the hash table. This storage is not exposed to the user, and is referred to
by all threads. In other words, these functions operate on one hash table
global to the process. The library serializes access to the table and attendant
data across threads using an internal mutex.
POSIX says much the same, but not so clearly. So:
o I can have only one symbol table; everything goes in it.
o If I write a utility subroutine, I don't know what my caller might
be doing; I might step on it.
Grrr. How could they!? What's an alternative? I'd like to avoid
quadratic behavior. The tsearch() family is nicer -- it lets me
choose a root. But it doesn't balance the tree -- its worst case
is when the entries arrive sorted, which mine almost are.
My colleague is doing a linear search of a few hundred entries.
It's plenty fast: computers are that way nowadays. But not
esthetic.
Thanks,
gil
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN