142
K
A
DAK
AMX Linked List Manager
12.3 Linked List Use
A list consists of a list header and objects linked to the list header by list nodes (or key
nodes). Storage for the list header must be provided by you. A pointer to the list header
acts as the list identifier.
An empty list is created by calling procedure ajlcre with a pointer to the list header
storage. When the list is created, you must specify the node offset (byte displacement) at
which link nodes (key nodes) will be found in objects which can reside on the list.
Once a list has been created, any object which has a link node (or key node) at that list's
node offset can be added to the list.
Objects can be inserted at or removed from the head or tail of the list. You can always
find the head or tail of the list. Given a pointer to any object on the list, you can find the
next or previous object, insert another object ahead of it or remove it from the list.
If the objects have a key node at the list's node offset, then the list is a keyed list. All
objects on a keyed list must have key nodes at the list's node offset. A new object is
added to a keyed list according to the key provided in the call to ajlinsk. The object
will be inserted into the list after all objects whose key is numerically less than or equal
to the specified key. Thus keyed objects are added after all other objects with the same or
lesser key.
The position of an object in a keyed list can be altered by calling ajlordk with a new key
for the object. The list will be reordered moving the specified object to the correct
position in the list according to its new key value. Reordering is usually faster than
removing the object with ajlrmvc and re-inserting with ajlinsk.