The RArray<> family of classes is more efficent (particularly time-wise) that the equivalent flat CArray<> classes. If you can't commit to using a flat array and need to dynamically choose between a ...Flat and ...Seg array then it obviously won't help.However, if you need to use a flat Carray<> class here are a few pointers. Say you had the following:
class CSemModel : public CBase
{
private:
CArrayPtrFlat iStar;
};
i) It is not good practice to have a C-class directly embedded inside another C-class, a pointer to the embedded C-class should be used:
class CSemModel : public CBase
{
...
private:
CArrayPtrFlat* iStar;
};
ii) Although not unknown, it is unusual to have an array of pointers to T-classes (especially T-classes as small as TStar). The T-classes have to live somewhere so they might as well live in the array itself. So the code changes to:
class CSemModel : public CBase
{
...
private:
CArrayFixFlat* iStar;
};
iii) The class definition should use the most abstract definition of the storage structure (in this case CArrayFix):
class CSemModel : public CBase
{
...
private:
CArrayFix* iStar;
};
Of course the implementation still uses CArrayFixFlat:
void CSemModel::ConstructL()
{
iStar = new (ELeave) CArrayFixFlat(EGranularity);
}
This allows the implementation to change from using CArrayFixFlat to CArrayFixSeg without changing the header file.