144
K
A
DAK
AMX Linked List Manager
void example(void)
{int i;
struct uobject *objp; /* Object pointer */
int nodeofs; /* Node offset */
nodeofs = (char *)(&objarray[0].keynode) - (char *)&objarray[0];
ajlcre(&keylist, nodeofs); /* Create empty keyed list */
nodeofs = (char *)(&objarray[0].listnode) - (char *)&objarray[0];
ajlcre(&extlist, nodeofs); /* Create empty extraction list*/
objp = &objarray[0]; /* First object */
for (i = 1; i <= NUMOBJ; i++) {
objp->id = i; /* Insert object id */
/* Add to list in random order */
ajlinsk(&keylist, objp++, random());
}
objp = ajlhead(&keylist); /* Find head of list */
while (objp != NULL) {
if (objp->id == 6)
break; /* Found object of interest */
objp = ajlnext(&keylist, objp);
}
if (objp != NULL) {
ajlrmvc(&keylist, objp); /* Remove object from keylist */
ajlinst(&extlist, objp); /* Add to extraction list */
}
}