NAME insert_alist - inserts an entry into an alist SYNOPSIS mixed insert_alist( mixed key, mixed data_or_key_list..., mixed * alist); DESCRIPTION inserts an entry into an alist, or shows the place where this is to be done. When called with the last argument being an alist: The first argument is a key to be inserted, the second and all the following but the last are data to associate it with. The last has to be an array with as much elements as key and data arguments are given, the matching key and data arrays; this should be already an alist, or the return value will neither be an alist. Return value is the enlarged assoc list ( array of two arrays ). If the key is already in the list, the data is simply replaced in the returned list. When called with the last argument beinig a list of non-lists: The call has to be done with exactly two arguments. The first argument is a key to be inserted in the presorted key list ( first element of an array that is an alist ) that has to be given as second argument. Return value is the index where the key has to be inserted to preserve the structure of a presorted alist, or the index where the key has been found. Return value is an int. CAVEATS: when called with certain string keys, the correct place might change after the call. So better don't use this mode of calling with a string key. Complexity O( lg(n) + a*n ) Where n is the number of keys and s is a very small constant ( for block move ); SEE ALSO LPC/alists order_alist assoc
Help topics available:
add_verb | assoc | create_wizard | extract | insert_alist |
order_alist | slice_array |
You are guest number 69 since November 2019.
This file was last modified: June 2000.