Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
CElementArray Class Reference

An advanced array class containing data that needs to be construct / destruct. More...

Detailed Description

An advanced array class containing data that needs to be construct / destruct.

CElementMethods provides some information about the data contained in the array.

#include <ElementArray.h>

Inheritance diagram for CElementArray:
CPointList C2DPointList C3DPointList C3DVectorList CUVWPointList CVCPointList CWeightPointList

Public Types

enum  GrowMode { GROW_DEFAULT = 0 , GROW_KEEP_MODE = -1 , GROW_DOUBLE_SIZE = -2 }
 
typedef enum CElementArray::GrowMode GrowMode
 

Public Member Functions

 CElementArray (CElementMethods *methods)
 Create an array. methods can be set to NULL when serializing (CElementMethods are created on the fly) or if SetMethods is called just after creation.
 
void SetMethods (CElementMethods *methods)
 
ElementType GetBaseTypeOfElement () const
 
ElementType GetTypeOfElement () const
 
SIZET GetSizeOfElement () const
 
void FreeExtra ()
 
int SetGrowFactor (int nGrowBy)
 
void PreAllocate (int estimatedSize)
 
void ConstructMode (bool constructAllOnce)
 
virtual void SetSize (int nNewSize, bool growOnly=false, int nGrowBy=GROW_KEEP_MODE)
 
virtual void Serialize (CXArchive &ar)
 
int GetSize () const
 
int GetUpperBound () const
 
virtual void RemoveAll ()
 
void SetAt (int nIndex, const void *newElement)
 
voidElementAt (int nIndex)
 
const voidElementAt (int nIndex) const
 
const voidGetFirst () const
 
const voidGetNext (const void *ptrObject) const
 
voidGetFirst ()
 
voidGetNext (void *ptrObject)
 
int Add (const void *newElement, int nGrowBy=GROW_KEEP_MODE)
 
void SetAtGrow (int nIndex, const void *newElement, int nGrowBy=GROW_KEEP_MODE)
 
voidoperator[] (int nIndex)
 
const voidoperator[] (int nIndex) const
 
int Append (const CElementArray &src, bool growOnly=false)
 
bool Copy (const CElementArray &src, bool growOnly=false)
 
bool Copy (int dstindex, int srcindex, const CElementArray &src)
 
virtual CElementArrayDuplicate (bool copydata) const
 
void InsertAt (int nIndex, void *newElement, int nCount=1)
 
void RemoveAt (int nIndex, int nCount=1)
 
void InsertAt (int nStartIndex, CElementArray *pNewArray)
 
bool Reorder (const unsigned int *reforder, unsigned int size, bool moveToDestinationIndexes)
 
unsigned int GetChecksum () const
 Return a checksum value made by bitwise operator that is a simple way to check if content changed between 2 calls.
 

Member Enumeration Documentation

◆ GrowMode

GrowMode control the way the array inflate while adding data.

Enumerator
GROW_DEFAULT 

A default grow mode which increase the array size by 1024 bytes each times its needed.

GROW_KEEP_MODE 

Keep the default grow size (SetAtGrow, SetSize)

GROW_DOUBLE_SIZE 

Double size the array for fast element growing (required when the final element number is not known, and is probably big)

Member Function Documentation

◆ ConstructMode()

void CElementArray::ConstructMode ( bool  constructAllOnce)

Can be use after Preallocate(XX) or SetSize(XX). This allow to construct all XX objects only once. Calling SetSize(YY, true) allow to resized down or up (to XX) without construction / destruction of elements. As element are construct once, elements can be leaved in an unknown state so this is to be used carefully. The mode remains valid until FreeExtra or ConstructMode(false) to go back to a normal mode

◆ PreAllocate()

void CElementArray::PreAllocate ( int  estimatedSize)

Preallocate array. GetSize() return 0. When filling the array, SetSize must be called with growOnly = true, otherwise array will be resized loosing the preallocation advantage

◆ SetSize()

virtual void CElementArray::SetSize ( int  nNewSize,
bool  growOnly = false,
int  nGrowBy = GROW_KEEP_MODE 
)
virtual

Set the new size of the array If the array is to small, the array size if increased by a factor depending on nGrowBy mode. If the array is too big, the array is resized unless growOnly = true if newSize = 0, the array is freed whatever growOnly value.

Reimplemented in CPointList.


The documentation for this class was generated from the following file: