Insertion
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:
Example:
...
OP l = callocobject();
init(LIST,l);
println(l);
...
|
This prints the message
on the terminal.
The typical operation is the insertion of a new object into a
list. This is done using the following routine:
- NAME: insert_list
- SYNOPSIS:
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.
There is also a test whether we are at the end of a list
- NAME: lastp_list
- SYNOPSIS: INT lastp_list(OP l)
- DESCRIPTION: true if next == NULL
For checking of the installation you can use
- NAME: test_list
- SYNOPSIS: INT test_list(OP l)
- DESCRIPTION:
harald.fripertinger "at" uni-graz.at, May 26,
2011