List of float values.
You will find a general example for the use of floatlist here.
List of float values. In opposition to other lists, the value "break" value of first/next and last/prev loops is not 0 but kMaxFloat.
static FloatList alloc()
Create a new empty list of type FloatList. The list must again be deleted using floatlist::release.
Name | Type | Default | Description |
Return | FloatList | New empty FloatList |
static int release(FloatList li)
Delete a list again that was created with floatlist::alloc.
Name | Type | Default | Description |
li | FloatList | - | List to be deleted |
static int length(FloatList li)
Ascertain the number of elements of a list.
Name | Type | Default | Description |
Return | int | Number of entries in the list | |
li | FloatList | - | List |
static float first(FloatList li)
Get the first non-empty entry record of a given FloatList. If nor more etries can found, the function returns the value kMaxFloat.
Name | Type | Default | Description |
Return | float | First value of the list. | |
li | FloatList | - | List with at least one element |
Create a FloatList and use some FloatList functions.
#include "internal/types.h"
int w_flist (FloatList fl, char * trailer) { float f;
if (strlen (trailer)) wlog ("", "%s\n", trailer);
for (f = floatlist::first (fl); f != kMaxFloat; f = floatlist::next (fl)) wlog ("", " %f\n", f);
return 0; }
int main () { FloatList fl = floatlist::alloc (); float f;
wlog ("", "kMaxFloat = %f\n", kMaxFloat);
floatlist::append (fl, 14.01); floatlist::append (fl, 17.02); floatlist::append (fl, 29.10); floatlist::insert (fl, 2, 26.11);
w_flist (fl, "List");
floatlist::sort (fl, 0); w_flist (fl, "Ascent sorted");
floatlist::sort (fl, 1); w_flist (fl, "Descent sorted");
floatlist::remove (fl, 14.01); w_flist (fl, "14.01 removed");
floatlist::release (fl);
return 0; }
static float next(FloatList li)
Get the next record of a given list. If nor more etries can found, the function returns the value kMaxFloat.
Name | Type | Default | Description |
Return | float | Next value of the list. | |
li | FloatList | - | List with at least one element after the current list pointer |
Create a FloatList and use some FloatList functions.
#include "internal/types.h"
int w_flist (FloatList fl, char * trailer) { float f;
if (strlen (trailer)) wlog ("", "%s\n", trailer);
for (f = floatlist::first (fl); f != kMaxFloat; f = floatlist::next (fl)) wlog ("", " %f\n", f);
return 0; }
int main () { FloatList fl = floatlist::alloc (); float f;
wlog ("", "kMaxFloat = %f\n", kMaxFloat);
floatlist::append (fl, 14.01); floatlist::append (fl, 17.02); floatlist::append (fl, 29.10); floatlist::insert (fl, 2, 26.11);
w_flist (fl, "List");
floatlist::sort (fl, 0); w_flist (fl, "Ascent sorted");
floatlist::sort (fl, 1); w_flist (fl, "Descent sorted");
floatlist::remove (fl, 14.01); w_flist (fl, "14.01 removed");
floatlist::release (fl);
return 0; }
static float prev(FloatList li)
Get the previous record of a given list. If nor more etries can found, the function returns the value kMaxFloat.
Name | Type | Default | Description |
Return | float | Preceding value in the list. | |
li | FloatList | - | List with at least one element after the current list pointer |
Create a FloatList and use some FloatList functions.
#include "internal/types.h"
int w_flist (FloatList fl, char * trailer) { float f;
if (strlen (trailer)) wlog ("", "%s\n", trailer);
for (f = floatlist::first (fl); f != kMaxFloat; f = floatlist::next (fl)) wlog ("", " %f\n", f);
return 0; }
int main () { FloatList fl = floatlist::alloc (); float f;
wlog ("", "kMaxFloat = %f\n", kMaxFloat);
floatlist::append (fl, 14.01); floatlist::append (fl, 17.02); floatlist::append (fl, 29.10); floatlist::insert (fl, 2, 26.11);
w_flist (fl, "List");
floatlist::sort (fl, 0); w_flist (fl, "Ascent sorted");
floatlist::sort (fl, 1); w_flist (fl, "Descent sorted");
floatlist::remove (fl, 14.01); w_flist (fl, "14.01 removed");
floatlist::release (fl);
return 0; }
static float last(FloatList li)
Get the last non-empty record of a given list. If nor more etries can found, the function returns the value kMaxFloat.
Name | Type | Default | Description |
Return | float | Last value of the list. | |
li | FloatList | - | List with at least one element |
Create a FloatList and use some FloatList functions.
#include "internal/types.h"
int w_flist (FloatList fl, char * trailer) { float f;
if (strlen (trailer)) wlog ("", "%s\n", trailer);
for (f = floatlist::first (fl); f != kMaxFloat; f = floatlist::next (fl)) wlog ("", " %f\n", f);
return 0; }
int main () { FloatList fl = floatlist::alloc (); float f;
wlog ("", "kMaxFloat = %f\n", kMaxFloat);
floatlist::append (fl, 14.01); floatlist::append (fl, 17.02); floatlist::append (fl, 29.10); floatlist::insert (fl, 2, 26.11);
w_flist (fl, "List");
floatlist::sort (fl, 0); w_flist (fl, "Ascent sorted");
floatlist::sort (fl, 1); w_flist (fl, "Descent sorted");
floatlist::remove (fl, 14.01); w_flist (fl, "14.01 removed");
floatlist::release (fl);
return 0; }
static int get_pos(
FloatList li,
float val,
int setPos = 0)
Search for the first position of a value in the list. If the value is not found, the function returns -1. List positions are 0-based, the first element has the position 0, the final the position length-1.
Name | Type | Default | Description |
Return | int | >= 0 : First occurrence of a value in the list -1 : Value not found |
|
li | FloatList | - | List in which the value is to be search for |
val | float | - | This value is searched for |
setPos | int | 0 | 0 : Leave list positions unchanged 1 : Set current list position at the point of finding |
static float get(
FloatList li,
int pos,
int setPos= 0)
Get the i-th element of the list. Wird kein Eintrag in der Liste gefunden, gibt die Funktion den Wert kMaxFloat zurück. List positions are 0-based, the first element has the position 0, the final the position length-1.
Name | Type | Default | Description |
Return | float | Value of the list at the position i or 0. | |
li | FloatList | - | List from which the element is to be fetched |
pos | int | - | 0-based list position |
setPos | int | 0 | 0 : Leave list positions unchanged 1 : Set current list position to pos |
static float append(FloatList li, float f)
Append a value to the list.
Name | Type | Default | Description |
Return | float | appended value or kMaxFloat | |
li | FloatList | - | List to which the append is to be made |
f | float | - | value to append |
static float insert(
FloatList li,
int pos,
float f)
Insert a value into the list.
Name | Type | Default | Description |
Return | float | inserted value or kMaxFloat | |
li | FloatList | - | List to which the insertion is to be made |
pos | int | - | 0-based position of inserted value |
f | float | - | value to insert |
static float remove(FloatList li, float val)
Remove the first occurence of an given value from the list.
Name | Type | Default | Description |
Return | int | removed value or kMaxFloat | |
li | FloatList | - | List from which the remove is to be made |
val | float | - | Value to be removed from the list |
static float remove_pos(FloatList li, int pos)
Remove a position from the list. List positions are 0-based, the first element has the position 0, the final the position length-1.
Name | Type | Default | Description |
Return | float | removed value or kMaxFloat | |
li | FloatList | - | List |
pos | int | - | 0-based delete position |
id = floatlist::remove_pos (0); if (id) float::release (id);
static int clear(FloatList li)
Remove all elements of the list
Name | Type | Default | Description |
Return | int | 1 : Action successful 0 : otherwise |
|
li | FloatList | - | List |
static int sort(FloatList li, int direction = 0)
Sort the list
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
li | FloatList | - | list to sort |
direction | int | 0 | Sort order 0 : ascent 1 : descent |
static char* to_xml(FloatList list, char* rootElementName = "floats")
Generate a XML structure of a FloatList object.
If you think about using this function, you might be interested in further information about cscript / java interaction. Related information can be found here.
Name | Type | Default | Description |
Return | char * | xml string or 0 on errors. The result string is valid until the next time a to_xml function is called and must not be changed or released. | |
list | FloatList | - | object |
rootElementName | String or char* | floats | name of the root element |
static FloatList from_xml(char* xml)
Create a FloatList object from a xml structure.
If you think about using this function, you might be interested in further information about cscript / java interaction. Related information can be found here.
Name | Type | Default | Description |
Return | FloatList | object of type FloatList. This list must be released using floatlist::release. | |
xml | String or char* | - | xml structure |
static int add_all(
FloatList target,
FloatList src,
int deleteFromSource)
Append all elements from list src to list target.
Create a FloatList and use some FloatList functions.
#include "internal/types.h"
int w_flist (FloatList fl, char * trailer) { float f;
if (strlen (trailer)) wlog ("", "%s\n", trailer);
for (f = floatlist::first (fl); f != kMaxFloat; f = floatlist::next (fl)) wlog ("", " %f\n", f);
return 0; }
int main () { FloatList fl = floatlist::alloc (); float f;
wlog ("", "kMaxFloat = %f\n", kMaxFloat);
floatlist::append (fl, 14.01); floatlist::append (fl, 17.02); floatlist::append (fl, 29.10); floatlist::insert (fl, 2, 26.11);
w_flist (fl, "List");
floatlist::sort (fl, 0); w_flist (fl, "Ascent sorted");
floatlist::sort (fl, 1); w_flist (fl, "Descent sorted");
floatlist::remove (fl, 14.01); w_flist (fl, "14.01 removed");
floatlist::release (fl);
return 0; }
Alphabetic index HTML hierarchy of classes or Java