|
Yate
|
A vector holding GenObjects. More...
#include <yateclass.h>
Public Member Functions | |
| ObjVector (bool autodelete=true, unsigned int allocChunk=0) | |
| ObjVector (unsigned int maxLen, bool autodelete=true, unsigned int allocChunk=0) | |
| ObjVector (ObjList &list, bool move=true, unsigned int maxLen=0, bool autodelete=true, unsigned int allocChunk=0) | |
| virtual | ~ObjVector () |
| virtual void * | getObject (const String &name) const |
| unsigned int | length () const |
| GenObject ** | data () |
| GenObject ** | data (unsigned int offs, unsigned int len=1) |
| const GenObject ** | data () const |
| const GenObject ** | data (unsigned int offs, unsigned int len=1) const |
| unsigned int | count () const |
| bool | null () const |
| GenObject * | at (unsigned int index) const |
| unsigned int | assign (ObjList &list, bool move=true, unsigned int maxLen=0) |
| unsigned int | insert (unsigned int pos, unsigned int items) |
| unsigned int | cut (unsigned int pos, unsigned int items, bool reAlloc=true) |
| unsigned int | cut (int items, bool reAlloc=true) |
| unsigned int | resize (unsigned int len, bool keepData=false, bool reAlloc=true) |
| unsigned int | compact (bool resizeToCount=false) |
| unsigned int | compact (unsigned int pos, int len) |
| GenObject * | take (unsigned int index) |
| bool | set (GenObject *obj, unsigned int index) |
| bool | appendObj (GenObject *obj) |
| bool | appendObj (GenObject *obj, bool fromStart, bool beforeNonNull=false) |
| bool | insertObj (GenObject *obj, unsigned int pos) |
| int | index (const GenObject *obj) const |
| int | index (const String &str) const |
| int | indexFree (bool fromStart, bool beforeNonNull=false) const |
| GenObject * | operator[] (unsigned int idx) const |
| GenObject * | operator[] (signed int idx) const |
| GenObject * | operator[] (const String &str) const |
| void | clear () |
| void | reset (unsigned int pos=0, int len=-1) |
| bool | autoDelete () |
| void | setDelete (bool autodelete) |
| unsigned int | allocChunk () const |
| void | allocChunk (unsigned int count) |
| unsigned int | size () const |
| Public Member Functions inherited from GenObject | |
| GenObject () | |
| virtual | ~GenObject () |
| virtual bool | alive () const |
| virtual void | destruct () |
| virtual const String & | toString () const |
| virtual const String & | traceId () const |
| NamedCounter * | getObjCounter () const |
| NamedCounter * | setObjCounter (NamedCounter *counter) |
Additional Inherited Members | |
| Static Public Member Functions inherited from GenObject | |
| static void * | getObject (const String &name, const GenObject *obj) |
| static bool | getObjCounting () |
| static void | setObjCounting (bool enable) |
| static NamedCounter * | getObjCounter (const String &name, bool create=true) |
| static ObjList & | getObjCounters () |
A vector holding GenObjects.
Simple vector class that holds objects derived from GenObject
|
inlineexplicit |
Constructor of a zero capacity vector
| autodelete | True to delete objects on destruct, false otherwise |
| allocChunk | How many items to allocate when needed to make space |
References allocChunk().
| ObjVector | ( | unsigned int | maxLen, |
| bool | autodelete = true, | ||
| unsigned int | allocChunk = 0 ) |
Constructor of an empty vector
| maxLen | Maximum number of objects the vector can hold |
| autodelete | True to delete objects on destruct, false otherwise |
| allocChunk | How many items to allocate when needed to make space |
References allocChunk().
| ObjVector | ( | ObjList & | list, |
| bool | move = true, | ||
| unsigned int | maxLen = 0, | ||
| bool | autodelete = true, | ||
| unsigned int | allocChunk = 0 ) |
Constructor from an object list
| list | List of objects to store in vector |
| move | True to move elements from list, false to just copy the pointer |
| maxLen | Maximum number of objects to put in vector, zero to put all |
| autodelete | True to delete objects on destruct, false otherwise |
| allocChunk | How many items to allocate when needed to make space |
References allocChunk().
|
virtual |
Destroys the vector and the objects if automatic delete is set
|
inline |
Retrieve the length of allocate chunk
Referenced by ObjVector(), ObjVector(), and ObjVector().
|
inline |
|
inline |
Append an object to vector
| obj | Object to store in vector |
References GenObject::GenObject(), length(), resize(), and set().
Referenced by appendObj(), and insertObj().
|
inline |
Append an object to vector. Trye to use a free (NULL) entry
| obj | Object to store in vector |
| fromStart | True to check from vector start, false to check from vector end in backward direction |
| beforeNonNull | Stop on first NULL object before first non NULL object |
References appendObj(), GenObject::GenObject(), indexFree(), and set().
| unsigned int assign | ( | ObjList & | list, |
| bool | move = true, | ||
| unsigned int | maxLen = 0 ) |
Clear the vector and assign objects from a list
| list | List of objects to store in vector |
| move | True to move elements from list, false to just copy the pointer |
| maxLen | Maximum number of objects to put in vector, zero to put all |
|
inline |
Get the object at a specific index in vector
| index | Index of the object to retrieve |
References GenObject::GenObject(), and index().
Referenced by operator[](), operator[](), and take().
|
inline |
Get the automatic delete flag
| void clear | ( | ) |
Clear the vector and optionally delete all contained objects
Referenced by resize().
|
inline |
| unsigned int compact | ( | unsigned int | pos, |
| int | len ) |
Compact vector, move non NULL pointers at given position
| pos | Vector position |
| len | Number of items to reset. Negative for all starting with given position |
| unsigned int count | ( | ) | const |
|
inline |
Remove items from vector
| items | Number of items to remove. Negative to remove from start, positive to remove from end |
| reAlloc | Re-allocate buffer. Set it it to false to move/reset data only |
References cut().
| unsigned int cut | ( | unsigned int | pos, |
| unsigned int | items, | ||
| bool | reAlloc = true ) |
|
inline |
Get a pointer to the stored data.
References GenObject::GenObject().
|
inline |
Get a pointer to the stored data.
References GenObject::GenObject().
|
inline |
Get a pointer to a byte range inside the stored data
| offs | Byte offset inside the stored data |
| len | Number of bytes that must be valid starting at offset |
References GenObject::GenObject().
|
inline |
Get a pointer to a byte range inside the stored data
| offs | Byte offset inside the stored data |
| len | Number of bytes that must be valid starting at offset |
References GenObject::GenObject().
|
virtual |
Get a pointer to a derived class given that class name
| name | Name of the class we are asking for |
Reimplemented from GenObject.
| int index | ( | const GenObject * | obj | ) | const |
Get the position in vector of a GenObject by a pointer to it
| obj | Pointer to the object to search for |
References GenObject::GenObject().
Referenced by at(), operator[](), set(), and take().
| int index | ( | const String & | str | ) | const |
| int indexFree | ( | bool | fromStart, |
| bool | beforeNonNull = false ) const |
Get the position in vector of the first or last NULL object
| fromStart | True to check from vector start, false to check from vector end in backward direction |
| beforeNonNull | Stop on first NULL object before first non NULL object |
Referenced by appendObj().
| unsigned int insert | ( | unsigned int | pos, |
| unsigned int | items ) |
Insert NULL items in vector
| pos | Vector position. Append if past vector length |
| items | Number of items to insert |
Referenced by insertObj(), and resize().
|
inline |
Insert an object in vector
| obj | Object to store in vector |
| pos | Vector position. Append if past vector length |
References appendObj(), GenObject::GenObject(), insert(), length(), and set().
|
inline |
Get the capacity of the vector
Referenced by appendObj(), insertObj(), and resize().
| bool null | ( | ) | const |
Check if the vector is empty
Indexing operator with GenObject string value to search
| str | String value (toString) of the object to search for |
References GenObject::GenObject(), and index().
|
inline |
Indexing operator with signed parameter
| idx | Index of the object to retrieve |
References at(), and GenObject::GenObject().
|
inline |
Indexing operator with unsigned parameter
| idx | Index of the object to retrieve |
References at(), and GenObject::GenObject().
| void reset | ( | unsigned int | pos = 0, |
| int | len = -1 ) |
Reset vector data. Delete reset item(s) if owned
| pos | Vector position |
| len | Number of items to reset. Negative to reset all items after given position |
Referenced by resize().
|
inline |
Resize the vector. Reset data if not kept Reset (release) vector data if same length and data is not kept
| len | New vector length |
| keepData | Keep old data |
| reAlloc | Re-allocate buffer. Set it it to false to move/reset data only |
References clear(), cut(), insert(), length(), and reset().
Referenced by appendObj(), and compact().
| bool set | ( | GenObject * | obj, |
| unsigned int | index ) |
Store an object in the vector
| obj | Object to store in vector |
| index | Index of the object to store |
References GenObject::GenObject(), and index().
Referenced by appendObj(), appendObj(), and insertObj().
|
inline |
Set the automatic delete flag
| autodelete | True to delete objects on destruct, false otherwise |
|
inline |
Retrieve vector size (total allocated items, including over alloc)
|
inline |
Retrieve and remove an object from the vector
| index | Index of the object to retrieve |
References at(), GenObject::GenObject(), and index().