87 lines
3.4 KiB
HTML
87 lines
3.4 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
|
|
<html>
|
|
<head>
|
|
<title>Lists</title>
|
|
<link href="style.css" rel="stylesheet" type="text/css">
|
|
</head>
|
|
<body background="images/back.gif">
|
|
<!--START-->
|
|
|
|
<h3>Lists</h3>
|
|
|
|
A list stores a collection of values in a particular order. You can add values
|
|
at the end or insert them somewhere in the middle of the list. You can address
|
|
the values using an index. Also you can sort the elements, either in ascending
|
|
or descending order. Lists can be used in many ways, for example to store
|
|
changing collections of values. They are implemented using simple arrays
|
|
but, as this is done in compiled code it is a lot faster than using an
|
|
array yourself. The following functions are available:
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>ds_list_create()</b></tt>
|
|
Creates a new list. The function returns an integer as an id that
|
|
must be used in all other functions to access the particular list.<br>
|
|
<tt><b>ds_list_destroy(id)</b></tt>
|
|
Destroys the list with the given id, freeing the memory used. Don't
|
|
forget to call this function when you are ready with the structure.<br>
|
|
<tt><b>ds_list_clear(id)</b></tt>
|
|
Clears the list with the given id, removing all data from it but not destroying it.<br>
|
|
<tt><b>ds_list_copy(id,source)</b></tt>
|
|
Copies the list source into the list with the given id.<br>
|
|
<tt><b>ds_list_size(id)</b></tt>
|
|
Returns the number of values stored in the list.<br>
|
|
<tt><b>ds_list_empty(id)</b></tt>
|
|
Returns whether the list is empty. This is the same as testing whether the size is 0.<br>
|
|
<tt><b>ds_list_add(id,val)</b></tt>
|
|
Adds the value at the end of the list.<br>
|
|
<tt><b>ds_list_insert(id,pos,val)</b></tt>
|
|
Inserts the value at position pos in the list. The first position is
|
|
0, the last position is the size of the list minus 1. <br>
|
|
<tt><b>ds_list_replace(id,pos,val)</b></tt>
|
|
Replaces the value at position pos in the list with the new value.<br>
|
|
<tt><b>ds_list_delete(id,pos)</b></tt>
|
|
Deletes the value at position pos in the list. (Position 0 is the first element.)<br>
|
|
<tt><b>ds_list_find_index(id,val)</b></tt>
|
|
Find the position storing the indicated value. If the value is not in the list -1 is returned.<br>
|
|
<tt><b>ds_list_find_value(id,pos)</b></tt>
|
|
Returns the value stored at the indicated position in the list.<br>
|
|
<tt><b>ds_list_sort(id,ascend)</b></tt>
|
|
Sorts the values in the list. When ascend is true the values are sorted
|
|
in ascending order, otherwise in descending order.<br>
|
|
<tt><b>ds_list_shuffle(id)</b></tt>
|
|
Shuffles the values in the list such that they end up in a random order.<br>
|
|
<tt><b>ds_list_write(id)</b></tt>
|
|
Turns the data structure into a string and returns this string. The string can then
|
|
be used to e.g. save it to a file. This provides an easy mechanism for saving data
|
|
structures.<br>
|
|
<tt><b>ds_list_read(id,str)</b></tt>
|
|
Reads the data structure from the given string (as created by the previous call).<br>
|
|
</blockquote>
|
|
|
|
<!--END-->
|
|
</body>
|
|
</html>
|
|
|
|
<!-- KEYWORDS
|
|
list
|
|
sorting
|
|
|
|
ds_list_create()
|
|
ds_list_destroy()
|
|
ds_list_clear()
|
|
ds_list_copy()
|
|
ds_list_size()
|
|
ds_list_empty()
|
|
ds_list_add()
|
|
ds_list_insert()
|
|
ds_list_replace()
|
|
ds_list_delete()
|
|
ds_list_find_index()
|
|
ds_list_find_value()
|
|
ds_list_sort()
|
|
ds_list_shuffle()
|
|
ds_list_write()
|
|
ds_list_read()
|
|
--> |