#include <Fl_Tree_Item_Array.H>
Public Member Functions | |
void | add (Fl_Tree_Item *val) |
Add an item* to the end of the array. | |
void | clear () |
Clear the entire array. | |
Fl_Tree_Item_Array (const Fl_Tree_Item_Array *o) | |
Copy constructor. Makes new copy of array, with new instances of each item. | |
Fl_Tree_Item_Array (int new_chunksize=10) | |
Constructor; creates an empty array. | |
void | insert (int pos, Fl_Tree_Item *new_item) |
Insert an item at index position pos . | |
const Fl_Tree_Item * | operator[] (int i) const |
Const version of operator[](int i). | |
Fl_Tree_Item * | operator[] (int i) |
Return the item and index i . | |
int | remove (Fl_Tree_Item *item) |
Remove the item from the array. | |
void | remove (int index) |
Remove the item at. | |
void | swap (int ax, int bx) |
Swap the two items at index positions ax and bx . | |
int | total () const |
Return the total items in the array, or 0 if empty. | |
~Fl_Tree_Item_Array () | |
Destructor. Calls each item's destructor, destroys internal _items array. |
Because FLTK 1.x.x. has mandated that templates and STL not be used, we use this class to dynamically manage the arrays.
None of the methods do range checking on index values; the caller must be sure that index values are within the range 0<index<total() (unless otherwise noted).
Fl_Tree_Item_Array::Fl_Tree_Item_Array | ( | int | new_chunksize = 10 |
) |
Constructor; creates an empty array.
The optional 'chunksize' can be specified to optimize memory allocation for potentially large arrays. Default chunksize is 10.
void Fl_Tree_Item_Array::add | ( | Fl_Tree_Item * | val | ) |
Add an item* to the end of the array.
Assumes the item was created with 'new', and will remain allocated.. Fl_Tree_Item_Array will handle calling the item's destructor when the array is cleared or the item remove()'ed.
void Fl_Tree_Item_Array::clear | ( | ) |
Clear the entire array.
Each item will be deleted (destructors will be called), and the array will be cleared. total() will return 0.
void Fl_Tree_Item_Array::insert | ( | int | pos, | |
Fl_Tree_Item * | new_item | |||
) |
Insert an item at index position pos
.
Handles enlarging array if needed, total increased by 1. If pos
== total(), an empty item is appended to the array.
int Fl_Tree_Item_Array::remove | ( | Fl_Tree_Item * | item | ) |
Remove the item from the array.
void Fl_Tree_Item_Array::remove | ( | int | index | ) |
Remove the item at.
[in] | index | from the array. |