MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame^] | 1 | CONCEPT |
| 2 | alists |
| 3 | |
| 4 | LAST UPDATE |
| 5 | 2 Mar 92 21:10:21 GMT |
| 6 | |
| 7 | AUTHOR |
| 8 | From: amylaar@mcshh.hanse.de (Joern Rennecke) |
| 9 | Subject: general documentation on alists |
| 10 | |
| 11 | DESCRIPTION |
| 12 | Alists provide a fast and convenient way to access data |
| 13 | associatively. |
| 14 | |
| 15 | Alists are implemented as arrays of arrays, the first being |
| 16 | the array holding the keys, the others arrays holding |
| 17 | associated data. An empty alist is an array of empty arrays. |
| 18 | |
| 19 | Note that the the dimensions of the arrays are used the other |
| 20 | way than in lisp to allow for faster searching. |
| 21 | |
| 22 | Keys have to be of type integer, string or object. Types can |
| 23 | be mixed. |
| 24 | |
| 25 | The search functions return an undefined value when another |
| 26 | list is given in place of a presorted key list. |
| 27 | |
| 28 | A list with non-numeric keys retrieved by restore_object() has |
| 29 | to be readjusted by using order_alist(), especially after |
| 30 | reboot. |
| 31 | |
| 32 | Deleting an entry can safely be done with exclude_array as |
| 33 | long as all associated data lists are treated like the key |
| 34 | array; index finding for such purposes can be done with assoc. |
| 35 | |
| 36 | Typical applications: holding administrary information about |
| 37 | wizards, list of visitors in a pub, list of customers having |
| 38 | some sort of credit, information remembered about items etc. |
| 39 | |
| 40 | NOTE |
| 41 | The main use of alists, storing data associatively, is now |
| 42 | better performed by mappings. Alists are needed for more |
| 43 | extreme situations only. |
| 44 | |
| 45 | Alists are available only if the driver is compiled with |
| 46 | alist support. In that case, __ALISTS__ is defined. |
| 47 | |
| 48 | HISTORY |
| 49 | LDMud 3.3 made alists an optional efun. |
| 50 | |
| 51 | SEE ALSO |
| 52 | mappings(LPC), order_alist(E), insert_alist(E), assoc(E), |
| 53 | transpose_array(E) |