47 #define FBSDK_DLL K_DLLIMPORT
55 #ifdef FBSDKUseNamespace
88 mItemPerBlock = pItemPerBlock;
99 *
this = pArrayTemplate;
115 if (pIndex>mArrayCount)
117 pIndex = mArrayCount;
120 if (mArrayCount>= mBlockCount*mItemPerBlock)
124 mArray = (Type *)
FBRealloc( mArray,(
size_t)(mBlockCount*mItemPerBlock*
sizeof(Type)));
127 if (pIndex<mArrayCount)
130 memmove (&(mArray[pIndex+1]),&(mArray[pIndex]),
sizeof(Type)*(mArrayCount-pIndex));
133 mArray[pIndex] = pItem;
144 assert( pIndex<mArrayCount );
145 if (pIndex+1<mArrayCount) {
146 memmove (&(mArray[pIndex]),&(mArray[pIndex+1]),
sizeof(Type)*(mArrayCount-pIndex-1));
149 memset (&(mArray[mArrayCount]),0,
sizeof(Type));
162 int Index = Find( pItem );
176 int Index = Find( pItem );
201 assert( pIndex<mArrayCount );
202 return mArray[pIndex];
209 inline void SetAt(
int pIndex,Type pItem)
211 assert( pIndex<mArrayCount );
212 mArray[pIndex] = pItem;
221 SetAt(mArrayCount-1,pItem );
236 if (pCount > mArrayCount)
240 const int lTempNewBlockCount = ( (
int) (mArrayCount+pCount + mItemPerBlock - 1 ) / mItemPerBlock );
241 const int lNewBlockCount = (lTempNewBlockCount > 1 ? lTempNewBlockCount : 1);
243 const int lOldArraySize = mArrayCount*
sizeof(Type);
244 const int lNewArraySize = lNewBlockCount*mItemPerBlock*
sizeof(Type);
246 if( lNewBlockCount > (
int) mBlockCount )
248 mArray = (Type *)
FBRealloc( mArray, (
size_t) lNewArraySize );
249 mBlockCount = lNewBlockCount;
252 memset( ((
char *)mArray) + lOldArraySize, 0, (
size_t) (lNewArraySize-lOldArraySize) );
253 mArrayCount += pCount;
257 mArrayCount = pCount;
267 assert( pIndex<mArrayCount );
268 return mArray[pIndex];
276 return mArray[mArrayCount-1];
286 for (Count=0; Count<mArrayCount; Count++) {
287 if (mArray[Count]==pItem) {
298 inline int Add( Type pItem )
300 return InsertAt( mArrayCount,pItem );
318 if (
this != &pArrayTemplate)
322 mItemPerBlock = pArrayTemplate.mItemPerBlock;
324 SetCount(pArrayTemplate.
GetCount());
325 memcpy(mArray, pArrayTemplate.mArray,
sizeof(Type) * pArrayTemplate.
GetCount());
360 #define FB_DEFINE_ARRAY( DllTag, Type ) \
361 typedef class DllTag FBArrayTemplate< FB##Type* > FBArray##Type;
368 #if defined(KARCH_DEV_INTEL)
369 #define FBImplementArray( DllTag, Type )
371 #define FBImplementArray( DllTag, Type ) \
372 template class DllTag FBSDKNamespaceFunc( FBArrayTemplate ) < FB##Type* >;
376 #ifdef FBSDKUseNamespace
379 #endif // __FBARRAY_H
Type & operator[](int pIndex) const
[] operator overload.
Type GetLast()
Get last item of the array.
Type GetAt(int pIndex)
Get item at pIndex.
class FBArrayTemplate< unsigned int > FBArrayUInt
FBArrayTemplate(const FBArrayTemplate< Type > &pArrayTemplate)
Copy constructor.
void RemoveAt(int pIndex)
Remove item at pIndex.
void SetCount(int pCount)
Set the number of items in the array.
#define FBSDK_DLL
Ensure that FBSDK_DLL is defined only once...
void FBFree(void *memblock)
General free function, actually calling standard function "free".
void Clear()
Empty the array of all items.
class FBArrayTemplate< bool > FBArrayBool
bool Remove(Type &pItem)
Remove pItem from the array.
bool RemoveIt(Type pItem)
Remove pItem from the array.
Type * GetArray()
Get a pointer to the array of items.
Py_ssize_t Py_ssize_t size
class FBArrayTemplate< int > FBArrayInt
class FBArrayTemplate< char * > FBArrayHChar
class FBArrayTemplate< int * > FBArrayHkInt
void RemoveLast()
Remove the last item in the array.
define declarations to determine cross-platform namespace conventions.
void SetAt(int pIndex, Type pItem)
Set item at pIndex to pItem.
~FBArrayTemplate()
Destructor.
class FBArrayTemplate< double > FBArrayDouble
int Add(Type pItem)
Add an item to the end of the array.
int GetCount() const
Get the number of items in the array.
int InsertAt(int pIndex, Type pItem)
Insert pItem at pIndex.
Template class to contain an array of items.
#define FBSDKNamespace
FBSDKNamespace define.
class FBArrayTemplate< bool * > FBArrayHBool
Pre-defined common used array types.
class FBArrayTemplate< float > FBArrayFloat
FBArrayTemplate(int pItemPerBlock=10)
Constructor.
void SetLast(Type pItem)
Set the last item of the array.
FBArrayTemplate< Type > & operator=(const FBArrayTemplate< Type > &pArrayTemplate)
Copy array of pointers without copying the associated objects.
class FBArrayTemplate< float * > FBArrayHkFloat
class FBArrayTemplate< unsigned int * > FBArrayHkUInt
int Find(Type pItem)
Find the index of pItem in the array.
class FBArrayTemplate< double * > FBArrayHkDouble
class FBArrayTemplate< void * > FBArrayHVoid
void * FBRealloc(void *memblock, size_t size)
General allocation function, actually calling standard function "realloc".
class FBArrayTemplate< char > FBArrayChar