[MUD-Dev] data structure design in a new mud

Ben Chambers bjchambers at phoenixdsl.com
Thu Mar 15 22:05:27 CET 2001


From: "J. Coleman" <stormknight at alltel.net>
> pauli.saksa at ztango.com wrote:
>>> From: "Justin Coleman" <JMCOLE at ENOREE.DJJ.STATE.SC.US>

>> A central list allows some operations that smaller lists do not,
>> e.g. fast searching of items.  Also general administrating of items
>> would be trivial to implement with a central list. There are down
>> sides as well.  How the indexing would be done? I.e. How to make a
>> difference between two similar items. I'd hate to force my
>> immortals to 'add item #24562 to this mob'.

Yes, it does allow some more operations, but the key is that these are
never the same.  Have each smaller list have numbers or something
similar.  Then, when those are removed, remove the item from the big
list using the number as an index to an array or something similar.
The central list is never going to be operated upon directly, and when
it is, it will edit the data from the smaller list.  Another
possibility, have the item data be something like

    item data //whatever your data is
    item *small_instance //pointer to the small instance it exists in.

Central list can then access small list if necessary.  The obvious
easiest way, however, is to have something along the lines of

    item data//whatever data
    item *small_instance //pointer to the small instance it exists in.
    int index //index in central list.

have a default deconstructor that removes it completely, i.e

    small_instance->remove();
    central_list->remove(index); //central list is the same for all objects

Basically, the two are seperate but contain data referencing each
other.  The key is, instead of pointers back forth and all over, you
simply link to the subset of data that it is stored under, and the
location in that subset.

_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev



More information about the mud-dev-archive mailing list