C3D Toolkit
Kernel - 117958, Vision - 2.7.6.12
|
Array of plain old data structures (POD). More...
#include <templ_s_array.h>
Public Types | |
typedef int(* | CompFunc) (const Type *, const Type *) |
A template of sorting function. | |
Public Member Functions | |
SArray (size_t i_max=0, uint16 i_delta=1) | |
Constructor. | |
SArray (const SArray< Type > &) | |
Copy constructor. | |
SArray (const std::vector< Type > &) | |
Copy constructor. | |
virtual | ~SArray () |
Destructor. | |
size_t | Upper () const |
The number of elements the memory is allocated for. | |
uint16 | Delta () const |
Get the increment by the number of elements while the allocation of additional memory. | |
void | Delta (uint16 newDelta) |
Set the increment by the number of elements while the allocation of additional memory (1 - autoincrement). | |
void | SetMaxDelta (uint16 newDelta) |
Set the maximum increment. | |
bool | SetSize (size_t newSize, bool clear) |
Functions that allocate potentially large memory, return an operation result (success/error). More... | |
bool | Reserve (size_t n, bool addAdditionalSpace=true) |
Reserve space for a given number of elements. | |
void | Flush () |
Set the number of elements to null. | |
void | HardFlush () |
Free the whole memory. | |
void | Adjust () |
Free the unnecessary memory. | |
Type * | Add () |
Add an element to the end of the array. | |
Type * | AddItems (size_t n) |
Add n elements to the end of the array. | |
Type * | Add (const Type &) |
Add an element to the end of the array. | |
Type * | AddAt (const Type &ent, size_t index) |
Insert an element by the index. | |
Type * | AddAfter (const Type &, size_t index) |
Add an element after the specified one. | |
Type * | InsertObj (const Type &index, const Type &ent) |
Insert an element before the specified one. | |
Type * | InsertInd (size_t index, const Type &) |
Insert an element before the specified one. | |
Type * | InsertInd (size_t index) |
Insert the empty element before the specified one. | |
void | Remove (Type *firstItr, Type *lastItr) |
Delete elements from the array from firstItr to lastItr-1 inclusively. | |
void | RemoveInd (size_t firstIdx, size_t lastIdx) |
Delete elements from the array from firstIdx to lastIdx-1 inclusively. | |
void | RemoveInd (size_t idx) |
Delete an element from array by the index. | |
size_t | RemoveObj (const Type &delObject) |
Delete an element from array. | |
bool | Fill (size_t fillCount, const Type &fillData) |
Fill an array. | |
bool | FillZero (size_t fillCount, size_t startIndex=0) |
Fill an array by bites consisting of 0. | |
size_t | FindIt (const Type &) const |
Return an index of the element in the array. | |
bool | IsExist (const Type &) const |
true if the element is found. | |
size_t | Count () const |
Get the number of elements in array. | |
ptrdiff_t | MaxIndex () const |
Get the number of elements in array. | |
bool | SetCArray (const Type *o, size_t count) |
Assign the value from the c-array. | |
void | Swap (SArray &arr) |
Swap data of arrays. | |
SArray< Type > & | operator= (const SArray< Type > &) |
Assignment operator. | |
SArray< Type > & | operator= (const std::vector< Type > &) |
Assignment operator. | |
SArray< Type > & | operator+= (const SArray< Type > &) |
Merging operator. | |
SArray< Type > & | operator+= (const std::vector< Type > &) |
Merging operator. | |
bool | operator== (const SArray< Type > &w) const |
Equality operator. More... | |
Type & | operator[] (size_t loc) const |
Access by index operator. | |
void | Sort (CompFunc comp=CompareSArrayItems< Type >) |
Sort the array. Sort in ascending order by default. | |
const Type * | GetAddr () const |
Get the address of the beginning of the array. | |
const Type * | GetEndAddr () const |
Get a pointer of the end (which follows the last element). | |
\~russian Унификация с контейнерами STL. | |
Unification with STL-compatible containers. | |
bool | empty () const |
Test whether vector is empty (i.e. whether its size is 0). | |
size_t | size () const |
Get the number of elements in array. | |
void | reserve (size_t n) |
Reserve space for a given number of elements. | |
void | resize (size_t n, Type val=Type()) |
Resizes the container so that it contains n elements. | |
size_t | capacity () const |
What is the number of elements the memory is allocated for? | |
void | push_back (const Type &e) |
Add an element to the end of the array. | |
void | pop_back () |
Removes the last element in the array, reducing the array size by one. | |
template<class Iterator > | |
void | insert (Iterator pos, const Type &e) |
Insert an element before the specified one. | |
template<class Iterator > | |
void | erase (Iterator pos) |
Delete an element from array by the index. | |
template<class Iterator > | |
void | erase (Iterator first, Iterator last) |
Delete elements from the array from first to last-1 inclusively. | |
void | clear () |
Set the number of elements to null. | |
void | shrink_to_fit () |
Free the unnecessary memory (Reduce capacity). | |
template<class Iterator > | |
void | assign (Iterator first, Iterator last) |
Assign new contents to the array, replacing its current contents. | |
void | assign (size_t n, const Type &val) |
Assign new contents to the array, replacing its current contents. | |
const Type * | begin () const |
Get the pointer to the first array element. | |
Type * | begin () |
Get the pointer to the first array element. | |
const Type * | end () const |
Get the pointer to the piece of memory after the array. | |
Type * | end () |
Get the pointer to the piece of memory after the array. | |
const Type * | cbegin () const |
Get the pointer to the first array element. | |
const Type * | cend () const |
Get the pointer to the piece of memory after the array. | |
const Type & | front () const |
Type & | front () |
const Type & | back () const |
Type & | back () |
Protected Member Functions | |
bool | CatchMemory () |
Catch memory. | |
bool | AddMemory (size_t n) |
Provide memory for n elements, independently from AutoDelta. | |
size_t | AutoDelta () const |
Calculate autoincrement. | |
TEMPLATE_FRIEND bool set_array_size | TEMPLATE_SUFFIX (SArray< Type > &, size_t newSize, bool clear) |
Reallocate memory. | |
TEMPLATE_FRIEND Type *add_n_to_array | TEMPLATE_SUFFIX (SArray< Type > &, size_t n) |
Add memory for n elements of the array and return a pointer to the beginning of the selected piece of memory. | |
TEMPLATE_FRIEND size_t find_in_array | TEMPLATE_SUFFIX (const SArray< Type > &, const Type &object) |
Find an element in the array. | |
TEMPLATE_FRIEND bool fill_array | TEMPLATE_SUFFIX (SArray< Type > &, size_t fillCount, const Type &fillData) |
Fill fillCount elements of the array by copies of the object fillData. | |
TEMPLATE_FRIEND bool fill_array_zero | TEMPLATE_SUFFIX (SArray< Type > &, size_t fillCount, size_t startIndex) |
Fill fillCount elements of the array by nulls. | |
TEMPLATE_FRIEND reader &CALL_DECLARATION | operator>>TEMPLATE_SUFFIX (reader &in, SArray< Type > &ref) |
Read operator. | |
TEMPLATE_FRIEND writer &CALL_DECLARATION | operator<<TEMPLATE_SUFFIX (writer &out, const SArray< Type > &ref) |
Write operator. | |
TEMPLATE_FRIEND reader &CALL_DECLARATION | operator>>TEMPLATE_SUFFIX (reader &in, SArray< Type > *&ptr) |
Read operator. | |
TEMPLATE_FRIEND writer &CALL_DECLARATION | operator<<TEMPLATE_SUFFIX (writer &out, const SArray< Type > *ptr) |
Write operator. | |
Protected Attributes | |
size_t | count |
The number of elements in array. | |
size_t | upper |
The number of elements the memory is allocated for. | |
uint16 | delta |
Increment by the number of elements while the allocation of additional memory. | |
Array of plain old data structures (POD).
A template array working with POD-only data that can be copied or moved in memory by 'memcpy' maintaining the validity of the object. For sample, the array should not contain objects which dynamically allocate memory, or classes with virtual functions.
|
inline |
Functions that allocate potentially large memory, return an operation result (success/error).
Set the new size of an array.
Equality operator.
An element-by-element comparison is performed with the ability to redefine the comparison operation using the overloading global function IsEqualSArrayItems.