If you have a list, the fundamental operation is insertion
into the list. So there are two steps, first the generation
of an empty LISTobject, and then the insertion into a list.
For the first step you simply call the
standard routine init(), see the following example:
This prints the message
OP l = callocobject();
on the terminal.
The typical operation is the insertion
of a new object into a list. This is done using the following routine:
There is also a test whether we are at the end of a list
- NAME: insert_list
INT insert_list(OP element, list,NULL,NULL)
- DESCRIPTION: inserts the element into the LISTobject list.
The second parameter list must be a LISTobject.
There is no test, whether
it is a LISTobject. This routine is called by the
general routine insert(), which has the same syntax.
The list is assumed to be ordered
in increasing order.
In the case when the first parameter element is a LISTobject
this routine is a merge of two lists.
In general it is not good to delete an element
which was inserted into list, because this destroys
the list, since it generates a hole in the list.
For checking of the installation you can use
- NAME: lastp_list
- SYNOPSIS: INT lastp_list(OP l)
- DESCRIPTION: true if next == NULL
- NAME: test_list
- SYNOPSIS: INT test_list(OP l)
last changed: November 19, 2001