Home2L - C/C++ API v1.4-0-g38cc (2024-05-25)
Smart Tools for a Private Home
|
Dynamic list.
A list stores an arbitrary number typed objects retaining the order of objects. Internally, the entries are stored in an array, which is dynamically resized as adequate.
The values are dynamically allocated objects, to which pointers are stored in the array. All 'Set...' methods require dynamic objects to be passed and take over their ownerships. On element deletion, these objects are deleted. It is legal to pass NULL to 'Set...' methods.
#include "base.H"
Public Member Functions | |
Read access ... | |
T * | Get (int idx) |
T * | operator[] (int idx) |
Write access ... | |
For any operations passing a new value object, the list takes over the ownership: The pointer passed as 'value' remains valid until the entry is deleted from the list. Then it will be free'd using 'delete'. | |
void | Set (int idx, T *value) |
Set (replace) a value. The entry must exist and 'idx' be valid. Complexity is O(1). | |
void | Insert (int idx, T *value) |
Insert a new value. Complexity is O(n). | |
void | Append (T *value) |
Append a new value. Complexity is O(1) if no resizing is necessary, else O(1). | |
T * | Disown (int idx) |
Disown a value and clear it in the array. | |
Public Member Functions inherited from CListRaw | |
int | Entries () const |
Get number of entries. | |
void | Clear () |
Clear the list. | |
void | Del (int idx) |
Delete entry; complexity is O(n). | |
virtual void | Dump (const char *name) |
Dump contents by means of INFO logs (for debugging) | |