GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmPODVector.h File Reference

Implementation of the GmPODVector template class. More...

#include "gmLog.h"
#include <qglobal.h>
#include "gmTrace.h"
#include <assert.h>
Include dependency graph for gmPODVector.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  GmPODVector< T, ControlSize, Grow, UseNew >
 A simple vector for Plain Old Data (POD) types with the control size variable type parameterized to allow for a smaller class size with ControlSize = unsigned int, with smaller vector size limits, or for a bigger class with ControlSize = size_t. Also receives as parameter the default growing strategy applied by its resize procedure and a flag stating if the memory allocation should be done in old C style (realloc / free) or in the new C++ style (operators new[] / delete[]). Using the old style is the default and allows us to, hopefully, benefit from realloc(). That can be an issue when using the takeData() method to transfer data ownership to other classes expecting to be able to release memory with operator delete[]. For those cases, set UseNew to true. More...
 

Typedefs

typedef size_t(* GmPODGrowT) (size_t s, size_t a)
 The type for the vector growing function used by GmPODVector. Parameter s is the desired number of items for the vector. Parameter a is the current available number of items in the vector and a < s. The function should return the new number of allocated items, making sure that it doesn't overflows the maximum value of the type used to control vector sizes (ControlSize parameter for the vector template).
 

Functions

template<class ControlSize >
size_t GmPODVectorSlowGrow (size_t s, size_t a)
 Vector growing by 25% of the current size.
 
template<class ControlSize >
size_t GmPODVectorStdGrow (size_t s, size_t a)
 Vector growing by 50% of the current size.
 
template<class ControlSize >
size_t GmPODVectorFastGrow (size_t s, size_t a)
 Vector growing by 100% of the current size.
 
size_t GmPODVectorTightGrow (size_t s, size_t a)
 Vector growing to exactly the needed size.
 

Detailed Description

Implementation of the GmPODVector template class.

Author
Carlos Augusto Teixeira Mendes
Date
April, 2024