Notes on lists v1.1a:

A data record stores an index in a singly linked list which is a pointer
to a data record in a file. For example, the Users.dat file would contain
all user's stats, and UserInv.dat could contain their inventory, pointed
to each other such as:

Users.dat     UserInv.dat
---------     -----------
User #1       User #1, item #1
User #2       User #1, item #2
.             User #2, item #1
.             User #1, item #3
.

then to find all inventory for User #1, the UserInv.dat file would need
to be searched for all items pointing to User #1. This could get slow if
the UserInv.dat file becomes huge, possibly pausing for 4-5 seconds is the
file is above 512 KB.

A solution to this delay is to implement a doubly linked list in which each
user's data record stores a pointer to the first inventory item, and each
item then points to the next item in the inventory file, terminating when
the next item is set to zero: for example:

Users.dat     UserInv.dat
---------     -----------
User #1       Item #1, next=2, prev=0
  First = 1   Item #2, next=4, prev=1
  Last = 4    Item #3, next=5, prev=0
              Item #4, next=0, prev=2
User #2       Item #5, next=0, prev=3
  First = 3
  Last = 5
...

Now the singly linked list does not have to be searched, only the first and
last pointers in the Users.dat file need to be used, and when next is zero,
then the end of the user's inventory is reached. Also note, the reason the
list is called 'doubly' linked is because the next pointer has a previous
pointer so the list could be searched in reverse, sorted, and repaired if
some items do not point correctly.

The following data files are doubly linked lists:

 RoomInv.Dat   --  Room inventory
 MonInv.Dat    --  Monster/Nonplayer inventory
 UserInv.Dat   --  User inventory
 TeamInv.Dat   --  Team inventory
 CtnInv.Dat    --  Container inventory for Users/Rooms.

The container file is a doubly linked list pointing to the user/room
inventory for the containers,

 Containr.Dat  --  Containers.

then the files Rooms.Dat and Users.Dat point to the Containr.Dat file,
which then points to the inventory lists, making the file a multiple
doubly linked list, as such:

User #1 First = Container #1 - Next=2 - Inventory #1 - First/Last
                Container #2 - Prev=1 - Inventory #2 ...
                               Next=4
User #1 Last  = Container #4 - Prev=2 - Inventory #3

User #2 First = Container #3 - Next=5 - Inventory #4
                Container #5 - Prev=3 - Inventory #5
                               Next=6
User #2 Last  = Container #6 - Prev=5 - Inventory #6

Room #1 First = Container #7 - Next=8 ...
                Container #8 - Prev=7
                               Next=9
Room #1 Last  = Container #9 - Prev=8

Room #2 First = Container #10- Next=11
                Container #11- Prev=10
                               Next=12
Room #2 Last  = Container #12- Prev=11

Technically then, the Containers are a dual-file (Rooms.dat/Users.dat)
doubly linked list pointing to (Containr.dat) which is a doubly linked list
pointing to (Ctninv.Dat). (loosely named a multiple doubly-linked list).

-end-

Linked list descriptions:

A list of items in one file which point to the data in a second file can be
implemented with a simple list (a singly linked list) in which each one of
the items pointed to is recorded in a list data file. The problem with this
is that to search for any given item, a loop through all the items must be
made. This can result in a very long delay if the data file containing the
items to be searched for is very great, such as 32,000 of them.

The solution is to create a doubly linked list. Then the first item is
recorded and each of the items pointed to also has linked to it the next
item. Then only the items needed to be searched for will be included in the
list. Examples:

Singly  linked list:

Room.Dat:   RoomInvFile.Dat:   Objects.Dat:
First ------> Index ---------->  Data

Data

Next -------> Index ---------->  Data
...
Next

Doubly linked list:

Room.Dat:   RoomInvFile.Dat:   Objects.Dat:
First ------> Prev (0)
              Index ---------->  Data
              Next --+
Data                 |
              Prev --+
              Index ---------->  Data
              Next --+
                     |
Last -------> Prev --+
              Index ---------->  Data
              Next (0)

-end-
