List of rectangles of type Rect.
You will find a general example for the use of rectlist here.
List of rectangles of type Rect.
static RectList alloc()
Create a new empty list of type RectList. The list must again be deleted using RectList::release.
Name | Type | Default | Description |
Return | RectList | New empty RectList |
int wrect (Rect r, char * trailer) { if (strlen (trailer)) wlog ("", "%s ", trailer);
wlog ("", "%f, %f, %f, %f\n", rect::left (r), rect::top (r), rect::right (r), rect::bottom (r));
return 0; }
int wrectlist (RectList rl, char * trailer) { Rect r;
if (strlen (trailer)) wlog ("", "%s\n", trailer);
for (r = rectlist::first (rl); r; r = rectlist::next (rl)) { wrect (r, " "); }
return 0; }
int main () { Rect r1 = rect::alloc (0.0, 0.0, 100.0, 200.0); Rect r2 = rect::alloc (80.0, 90.0, 110.0, 210.0); Rect r3 = rect::alloc (80.0, 90.0, 400.0, 500.0); Rect intersect = rect::alloc (); RectList rl = rectlist::alloc ();
rectlist::append (rl, r1); rectlist::append (rl, r2); rectlist::append (rl, r3); wrectlist (rl, "RectList");
rectlist::bbox (rl, intersect); wrect (intersect, "BBox of rectlist");
return 0; }
static int release(RectList li)
Delete a list again that was created with RectList::alloc.
Name | Type | Default | Description |
li | RectList | - | List to be deleted |
static int length(RectList li)
Ascertain the number of elements of a list.
Name | Type | Default | Description |
Return | int | Number of entries in the list | |
li | RectList | - | List |
static Rect first(RectList li)
Get the first non-empty entry record of a given RectList. If nor more etries can found, the function returns the value 0.
Name | Type | Default | Description |
Return | Rect | First value of the list. | |
li | RectList | - | List with at least one element |
int wrect (Rect r, char * trailer) { if (strlen (trailer)) wlog ("", "%s ", trailer);
wlog ("", "%f, %f, %f, %f\n", rect::left (r), rect::top (r), rect::right (r), rect::bottom (r));
return 0; }
int wrectlist (RectList rl, char * trailer) { Rect r;
if (strlen (trailer)) wlog ("", "%s\n", trailer);
for (r = rectlist::first (rl); r; r = rectlist::next (rl)) { wrect (r, " "); }
return 0; }
int main () { Rect r1 = rect::alloc (0.0, 0.0, 100.0, 200.0); Rect r2 = rect::alloc (80.0, 90.0, 110.0, 210.0); Rect r3 = rect::alloc (80.0, 90.0, 400.0, 500.0); Rect intersect = rect::alloc (); RectList rl = rectlist::alloc ();
rectlist::append (rl, r1); rectlist::append (rl, r2); rectlist::append (rl, r3); wrectlist (rl, "RectList");
rectlist::bbox (rl, intersect); wrect (intersect, "BBox of rectlist");
return 0; }
Get the next record of a given list. If nor more etries can found, the function returns the value 0.
Name | Type | Default | Description |
Return | Rect | Next value of the list. | |
li | RectList | - | List with at least one element after the current list pointer |
int wrect (Rect r, char * trailer) { if (strlen (trailer)) wlog ("", "%s ", trailer);
wlog ("", "%f, %f, %f, %f\n", rect::left (r), rect::top (r), rect::right (r), rect::bottom (r));
return 0; }
int wrectlist (RectList rl, char * trailer) { Rect r;
if (strlen (trailer)) wlog ("", "%s\n", trailer);
for (r = rectlist::first (rl); r; r = rectlist::next (rl)) { wrect (r, " "); }
return 0; }
int main () { Rect r1 = rect::alloc (0.0, 0.0, 100.0, 200.0); Rect r2 = rect::alloc (80.0, 90.0, 110.0, 210.0); Rect r3 = rect::alloc (80.0, 90.0, 400.0, 500.0); Rect intersect = rect::alloc (); RectList rl = rectlist::alloc ();
rectlist::append (rl, r1); rectlist::append (rl, r2); rectlist::append (rl, r3); wrectlist (rl, "RectList");
rectlist::bbox (rl, intersect); wrect (intersect, "BBox of rectlist");
return 0; }
Get the previous record of a given list. If nor more etries can found, the function returns the value 0.
Name | Type | Default | Description |
Return | Rect | Preceding value in the list. | |
li | RectList | - | List with at least one element after the current list pointer |
Get the last non-empty record of a given list. If nor more etries can found, the function returns the value 0.
Name | Type | Default | Description |
Return | Rect | Last value of the list. | |
li | RectList | - | List with at least one element |
static int get_pos(
RectList li,
Rect 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 | RectList | - | List in which the value is to be search for |
val | Rect | - | This value is searched for |
setPos | int | 0 | 0 : Leave list positions unchanged 1 : Set current list position at the point of finding |
static int get_pos_by_value(
RectList li,
float l,
float t,
float r,
float b,
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 | RectList | - | List in which the value is to be search for |
l, t, r, b | float, float, float, float | - | left, top, right, bottom components of the rectangle |
setPos | int | 0 | 0 : Leave list positions unchanged 1 : Set current list position at the point of finding |
static Rect get(
RectList 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 0 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 | Rect | Value of the list at the position i or 0. | |
li | RectList | - | 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 Rect append(RectList li, Rect f)
Append a value to the list.
Name | Type | Default | Description |
Return | Rect | appended value or 0 | |
li | RectList | - | List to which the append is to be made |
f | Rect | - | value to append |
static Rect append_by_value(
RectList li,
float l,
float t,
float r,
float b)
Append a rectangle given by its components to the list.
Name | Type | Default | Description |
Return | Rect | appended value or 0 | |
li | RectList | - | List to which the append is to be made |
l, t, r, b | float, float, float, float | - | left, top, right, bottom components of the rectangle |
static Rect insert(
RectList li,
int pos,
Rect f)
Insert a value into the list.
Name | Type | Default | Description |
Return | Rect | inserted value or 0 | |
li | RectList | - | List to which the insertion is to be made |
pos | int | - | 0-based position of inserted value |
f | Rect | - | value to insert |
static Rect insert_by_value(
RectList li,
int pos,
float l,
float t,
float r,
float b)
Insert a rectangle given by its components into the list.
Name | Type | Default | Description |
Return | Rect | appended value or 0 | |
li | RectList | - | List to which the append is to be made |
pos | int | - | 0-based position of inserted value |
l, t, r, b | float, float, float, float | - | left, top, right, bottom components of the rectangle |
static Rect remove(RectList li, Rect val)
Remove the first occurence of an given value from the list.
Name | Type | Default | Description |
Return | int | removed value or 0 | |
li | RectList | - | List from which the remove is to be made |
val | Rect | - | Value to be removed from the list |
static Rect remove_by_value(
RectList li,
float l,
float t,
float r,
float b)
Remove the first occurence of a rectangle givem by its components from the list.
Name | Type | Default | Description |
Return | int | removed value or 0 | |
li | RectList | - | List from which the remove is to be made |
l, t, r, b | float, float, float, float | - | left, top, right, bottom components of the rectangle |
static Rect remove_pos(RectList 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 | Rect | removed value or 0 | |
li | RectList | - | List |
pos | int | - | 0-based delete position |
id = RectList::remove_pos (0); if (id) rect::release (id);
static int clear(RectList li)
Remove all elements of the list
Name | Type | Default | Description |
Return | int | 1 : Action successful 0 : otherwise |
|
li | RectList | - | List |
static int bbox(RectList li, Rect res)
Get the rectangles bounding box.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
li | RectList | - | list to sort |
res | Rect | - | allocated Rect for the result |
int wrect (Rect r, char * trailer) { if (strlen (trailer)) wlog ("", "%s ", trailer);
wlog ("", "%f, %f, %f, %f\n", rect::left (r), rect::top (r), rect::right (r), rect::bottom (r));
return 0; }
int wrectlist (RectList rl, char * trailer) { Rect r;
if (strlen (trailer)) wlog ("", "%s\n", trailer);
for (r = rectlist::first (rl); r; r = rectlist::next (rl)) { wrect (r, " "); }
return 0; }
int main () { Rect r1 = rect::alloc (0.0, 0.0, 100.0, 200.0); Rect r2 = rect::alloc (80.0, 90.0, 110.0, 210.0); Rect r3 = rect::alloc (80.0, 90.0, 400.0, 500.0); Rect intersect = rect::alloc (); RectList rl = rectlist::alloc ();
rectlist::append (rl, r1); rectlist::append (rl, r2); rectlist::append (rl, r3); wrectlist (rl, "RectList");
rectlist::bbox (rl, intersect); wrect (intersect, "BBox of rectlist");
return 0; }
int wrect (Rect r, char * trailer) { if (strlen (trailer)) wlog ("", "%s ", trailer);
wlog ("", "%f, %f, %f, %f\n", rect::left (r), rect::top (r), rect::right (r), rect::bottom (r));
return 0; }
int wrectlist (RectList rl, char * trailer) { Rect r;
if (strlen (trailer)) wlog ("", "%s\n", trailer);
for (r = rectlist::first (rl); r; r = rectlist::next (rl)) { wrect (r, " "); }
return 0; }
int main () { Rect r1 = rect::alloc (0.0, 0.0, 100.0, 200.0); Rect r2 = rect::alloc (80.0, 90.0, 110.0, 210.0); Rect r3 = rect::alloc (80.0, 90.0, 400.0, 500.0); Rect intersect = rect::alloc (); RectList rl = rectlist::alloc ();
rectlist::append (rl, r1); rectlist::append (rl, r2); rectlist::append (rl, r3); wrectlist (rl, "RectList");
rectlist::bbox (rl, intersect); wrect (intersect, "BBox of rectlist");
return 0; }
Alphabetic index HTML hierarchy of classes or Java