Re: arrays vs linked lists

From: George (greerga@circlemud.org)
Date: 01/06/99


On Tue, 5 Jan 1999, Invincibill wrote:

>circlemud utilizes arrays(or tables if you prefer) to store its world
>files. i realize the tables are magrinally smaller and at times quicker,

Save 4 bytes per item minus the original 4 byte array pointer overhead.
Much faster random because you pointer arithmetic one pointer instead of
walking all over memory loading random pieces in search of the one you
want.

>but dont you all think that linked lists are better? you would also have
>less problems with segmentation faults and its much easier to avoid

More pointers to corrupt with linked lists, probably more problems. :)

>memory leaks with linked lists(IMHO). also, you could add a little more
>abstraction to it and possibly cut down on the code a bit.

Could, probably will moreso than current.

>i'm wondering if anybody has undertaken converting the whole info_storage
>scheme into linked lists.

I think Ebon Mists MUD did, but it's been awhile since I read his message.
He said it cut down loading time and made it much easier to do OLC with.

>you can more easily utilize faster search routines(BST's etc; i realize
>you can implement a bst with an array but its really really nasty)

Arrays are generally easier to search because you have a known pattern of
placement in memory.  However, it depends on your application.

>i have not, for the life of me, been able to undersand why it was done
>this way in the first place.(and i'm sure its because of something i
>dont know, because i'm sure Jer is a helluva lot better coder than i)

Probably because Diku did it that way.  And if you've looked at Diku's
code, you'll wonder why they did it that way.  (allocate_room() is ugly)

So in short, history.

--
George Greer, greerga@circlemud.org | Genius may have its limitations, but
http://mouse.van.ml.org/   (mostly) | stupidity is not thus handicapped.
http://www.van.ml.org/CircleMUD/    |                  -- Elbert Hubbard


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST