When there is ordering involved, as Jason mentions, hashes/arrays don't
work so great.  Random access to an arbitrary element is fast, but there
has to be another data structure to remember the order.

Lots of times we combine the two: put the data in hashes/arrays with keys,
then keep a list containing the keys in the order you want.  This lets us
store lots of data with each key without keeping all of it in a list,
access it randomly very fast, and also access it sequentially in order(s).

Jim

>
> To answer your question, there's no way to avoid the "Tcl tax" in
> AOLserver.  But maybe that's not a bad thing.
>
> The linked lists are setting off warning alarms in my head.  Linked lists
> are terrific if most of what you do is accessing your data items in a
> serialized stream, but if you are going to be accessing an item here or an
> item there,  you'll waste a lot of time traversing the list getting to the
> item you want (unless your lists are very short), as compared with using
> something else like, say, a hash.  But you don't want to implement hashes,
>   you say?  As it turns out, Tcl is not just an interpreter, it's a library,
>   and you can create hashes from C and maintain them, all without ever
> messing with any actual Tcl language stuff.  And the Tcl libraries are
> pretty good about bucket management and garbage collection when you use
> them to manage your hashes.  Since you haven't told us much about your
> underlying problem, I can't really say that linked lists are inappropriate
> as a solution, but you should take a look at the functions in the Tcl
> libraries related to hashes and see if they might serve your needs better.
>    Also, I think AOLserver has C-based cache functions which allow you to
> dedicate a chunk of memory to a hash-based cache, which might be even more
> stuff you can use.
>
> (No idea about ColdStore, sorry.)
>
> Pete.
>
> On Sunday, April 14, 2002, at 10:32 PM, Jason Saunders wrote:
>
> > I'm designing a site written entirely in C-based modules - much of the
> > work
> > the modules do involves storing and reading small items of data (in the
> > order of 40 bytes) in linked lists. The data will also stored in a
> > database
> > for backup, and for more general access. The reason to store it in linked
> > lists is that it will be faster to store it in sorted form and then read
> > directly from main memory, rather than read it from a database, sort it,
> > build a linked list, manipulate the data, write to the database and then
> > free the list.
>

Reply via email to