AMX Linked List Manager
K
A
DAK
143
The following example coded in C illustrates the use of the Linked List Manager. An
object called uobject is defined with a key node at offset keynode in the object. An
array of ten objects is provided. A keyed list keylist is created and the ten objects are
added to the list in random order. The list is then perused to locate the actual position in
the list of the sixth object in the array. The object is removed from the keyed list and
added to the tail of a simple doubly linked list called extlist.
#include "amx831sd.h" /* AMX Structure Definitions */
extern unsigned int random(); /* Random number generator */
struct uobject {
int id; /* Object identifier */
int data; /* Other application data */
struct amxlks keynode; /* Key node */
char moredata[10]; /* More application data */
struct amxlns listnode; /* List node */
int lastdata; /* Last application data */
};
/* Local variables */
static struct amxlhs keylist; /* Keyed list header */
static struct amxlhs extlist; /* Extraction list */
#define NUMOBJ 10 /* Ten objects */
/* Array of objects */
static struct uobject objarray[NUMOBJ];