StrArray is an array of character strings and maintains them in sorted order
#include <arr.h>
Inheritance diagram for jvar::StrArray:
Collaboration diagram for jvar::StrArray:Public Types | |
| enum | { FLAG_FIXEDBUF = 0x1 } |
| typedef int(* | Compare )(const void *, const void *) |
Public Member Functions | |
| std::string * | add (const char *keyelem) |
| bool | remove (const char *keyelem) |
| std::string * | find (const char *elem) |
| std::string * | insert (int pos) |
| void * | insert (int pos, const void *elem) |
| std::string * | insertCustom (int pos) |
| std::string * | append () |
| void * | append (const void *elem) |
| std::string * | addOrModify (const std::string *keyelem, bool modifyfound=true) |
| void * | addOrModify (const void *elem, bool modifyfound=true) |
| std::string * | add (const std::string *keyelem) |
| void * | add (const void *elem) |
| bool | remove (const std::string *keyelem) |
| bool | remove (int pos) |
| bool | remove (const void *elem) |
| std::string * | find (const std::string *elem) |
| void * | find (const void *elem) |
| std::string * | get (int pos) |
| bool | forEach (Iter< std::string > &iter) |
| bool | forEachReverse (Iter< std::string > &iter) |
| void | useFixedMem (void *memptr, int *countptr, int maxlen) |
| void | clear () |
| int | length () |
| bool | full () |
| void | sort (Compare comp=NULL) |
| bool | findPos (const void *findelem, int &pos) |
| void | reserve (int elemcount) |
Static Public Member Functions | |
| static int | compare (const void *e1, const void *e2) |
Public Attributes | |
| uint | mFlags |
Protected Member Functions | |
| void | copyFrom (BArray &src, bool alloconly, bool move) |
| bool | binSearch (const void *findelem, int &pos) |
| void | ensureAlloc (int desiredlen) |
anonymous enum [inherited] |
| void* jvar::BArray::add | ( | const void * | elem | ) | [inline, inherited] |
Adds an element in order using the compare function
| elem | Pointer to the element which will be copied |
References jvar::BArray::addOrModify().
| std::string * jvar::ObjArray< std::string >::add | ( | const std::string * | keyelem | ) | [inline, inherited] |
Adds an item based to the array keeping it sorted
| keyelem | Element to add |
| std::string* jvar::StrArray::add | ( | const char * | keyelem | ) | [inline] |
Adds a string to the array
| keyelem | String to add |
| void * jvar::BArray::addOrModify | ( | const void * | elem, |
| bool | modifyfound = true |
||
| ) | [inherited] |
Adds an element or modifies it if it already exists
| elem | Pointer to element which will be copied |
| modifyfound | Should it be modified (true=allow, false=don't allow) |
References jvar::BArray::insert().
Referenced by jvar::BArray::add().
| std::string * jvar::ObjArray< std::string >::addOrModify | ( | const std::string * | keyelem, |
| bool | modifyfound = true |
||
| ) | [inline, inherited] |
Adds a new element or modifies it if exists.
| keyelem | Element to search and add if doesn't exist or modify |
| modifyfound | Allow modifying the lement |
| void* jvar::BArray::append | ( | const void * | elem | ) | [inline, inherited] |
Appends or adds an element at the end of the array
| elem | Pointer to the element which will be copied |
References jvar::BArray::insert(), and jvar::BArray::length().
Referenced by jvar::ObjArray< int >::append().
| std::string * jvar::ObjArray< std::string >::append | ( | ) | [inline, inherited] |
Appends a new element at the end of the array
| void jvar::BArray::clear | ( | ) | [inherited] |
Deletes all elements
References jvar::BArray::FLAG_FIXEDBUF, jvar::Buffer::free(), and jvar::BArray::mFlags.
Referenced by jvar::PropArray< Variant >::clear().
| void * jvar::BArray::find | ( | const void * | elem | ) | [inherited] |
Finds an element in array that matches the provided element
| elem | Pointer to an element to search |
| std::string * jvar::ObjArray< std::string >::find | ( | const std::string * | elem | ) | [inline, inherited] |
Finds the item
| elem | Element to find (only the key is used) |
| std::string* jvar::StrArray::find | ( | const char * | elem | ) | [inline] |
Finds a string in the array
| elem | String to find |
| bool jvar::BArray::findPos | ( | const void * | findelem, |
| int & | pos | ||
| ) | [inline, inherited] |
Finds the position of an element
| findelem | Pointer to an element to search |
| pos | Returns the position of the found element |
| bool jvar::ObjArray< std::string >::forEach | ( | Iter< std::string > & | iter | ) | [inline, inherited] |
Returns an iterator to go over elements of the array in order
| iter | Iterator |
| bool jvar::ObjArray< std::string >::forEachReverse | ( | Iter< std::string > & | iter | ) | [inline, inherited] |
Returns an iterator go over elements in reverse order
| iter | Iterator |
| bool jvar::BArray::full | ( | ) | [inline, inherited] |
Determines if the array is at capacity.
Referenced by jvar::BArray::insert().
| std::string * jvar::ObjArray< std::string >::get | ( | int | pos | ) | [inline, inherited] |
Returns an element from the array
| pos | Position of retrieve the element |
Reimplemented from jvar::BArray.
| void * jvar::BArray::insert | ( | int | pos, |
| const void * | elem | ||
| ) | [inherited] |
Insert an element into the array
| pos | Position to insert at |
| elem | Pointer to element which will be copied |
References jvar::BArray::FLAG_FIXEDBUF, jvar::BArray::full(), jvar::BArray::length(), and jvar::BArray::mFlags.
Referenced by jvar::BArray::addOrModify(), jvar::ObjArray< int >::addOrModify(), jvar::BArray::append(), and jvar::ObjArray< int >::insert().
| std::string * jvar::ObjArray< std::string >::insert | ( | int | pos | ) | [inline, inherited] |
Inserts a new element at the provided position in the array
| pos | Position to insert |
| std::string * jvar::ObjArray< std::string >::insertCustom | ( | int | pos | ) | [inline, inherited] |
Inserts an element at the provided position in the array. The new element is not constructed by ths call. The caller uses "inplace new" to call a non-default constructor.
| pos | Position to insert |
| int jvar::BArray::length | ( | ) | [inline, inherited] |
Returns the number of elements in the array
Referenced by jvar::PropArray< Variant >::addOrModify(), jvar::BArray::append(), jvar::ObjArray< int >::forEach(), jvar::PropArray< Variant >::forEach(), jvar::ObjArray< int >::forEachReverse(), jvar::PropArray< Variant >::forEachSort(), jvar::ObjArray< int >::get(), jvar::BArray::insert(), jvar::PropArray< Variant >::length(), and jvar::BArray::remove().
| bool jvar::BArray::remove | ( | const void * | elem | ) | [inherited] |
Removes an element from array that matches the provided element
| elem | Pointer to an element to search |
| bool jvar::ObjArray< std::string >::remove | ( | const std::string * | keyelem | ) | [inline, inherited] |
Removes an item using a key
| keyelem | Element to remove (only key is used) |
| bool jvar::ObjArray< std::string >::remove | ( | int | pos | ) | [inline, inherited] |
Removes an element from the provided position
| pos | Position to remove the item |
Reimplemented from jvar::BArray.
| bool jvar::StrArray::remove | ( | const char * | keyelem | ) | [inline] |
Removes a string from the array
| keyelem | String to remove |
| void jvar::BArray::reserve | ( | int | elemcount | ) | [inline, inherited] |
Ensures that the array has at least the specified allocation
| elemcount | Number of element to reserve |
| void jvar::BArray::sort | ( | Compare | comp = NULL | ) | [inline, inherited] |
Sorts the array
| comp | Compare function (if NULL, the one from constructor is used) |
| void jvar::BArray::useFixedMem | ( | void * | memptr, |
| int * | countptr, | ||
| int | maxlen | ||
| ) | [inherited] |
Enters fixed memory mode using the provided memory
| memptr | Pointer to allocated fixed memory |
| countptr | Pointer to a variable where current count is held |
| maxlen | Maximum number of elements (size specified in constructor) |
References jvar::BArray::FLAG_FIXEDBUF, jvar::Buffer::free(), and jvar::BArray::mFlags.
uint jvar::BArray::mFlags [inherited] |
Flags for this array
Referenced by jvar::BArray::clear(), jvar::BArray::insert(), jvar::BArray::remove(), and jvar::BArray::useFixedMem().