FBConstructionOperationArray Class Reference
 
 
 
FBConstructionOperationArray Class Reference

#include <fbconstructionhistory.h>


Class Description

Definition at line 101 of file fbconstructionhistory.h.

Inheritance diagram for FBConstructionOperationArray:
FBArrayTemplate< FBConstructionOperation * >

Public Member Functions

  FBConstructionOperationArray ()
  Constructor.
  ~FBConstructionOperationArray ()
  Destructor.
int  InsertAt (int pIndex, FBConstructionOperation *pItem)
  Insert pItem at pIndex.
void  RemoveAt (int pIndex)
  Remove item at pIndex.
void  RemoveLast ()
  Remove the last item in the array.
bool  Remove (FBConstructionOperation *&pItem)
  Remove pItem from the array.
bool  RemoveIt (FBConstructionOperation *pItem)
  Remove pItem from the array.
void  Clear ()
  Empty the array of all items.
FBConstructionOperation *&  operator[] (int pIndex) const
  [] operator overload.
void  SetAt (int pIndex, FBConstructionOperation *pItem)
  Set item at pIndex to pItem.
void  SetLast (FBConstructionOperation *pItem)
  Set the last item of the array.
int  GetCount () const
  Get the number of items in the array.
void  SetCount (int pCount)
  Set the number of items in the array.
FBConstructionOperation GetAt (int pIndex)
  Get item at pIndex.
FBConstructionOperation GetLast ()
  Get last item of the array.
int  Find (FBConstructionOperation *pItem)
  Find the index of pItem in the array.
int  Add (FBConstructionOperation *pItem)
  Add an item to the end of the array.
FBConstructionOperation **  GetArray ()
  Get a pointer to the array of items.

Constructor & Destructor Documentation

FBConstructionOperationArray::FBConstructionOperationArray ( )

Constructor.

FBConstructionOperationArray::~FBConstructionOperationArray ( )

Destructor.


Member Function Documentation

int FBArrayTemplate< FBConstructionOperation * >::InsertAt ( int  pIndex,
FBConstructionOperation pItem 
) [inline, inherited]

Insert pItem at pIndex.

Parameters:
pIndex Index to insert at.
pItem Item to insert.
Returns:
Actual insertion index where pItem was inserted.

Definition at line 113 of file fbarray.h.

        {
                if (pIndex>mArrayCount) 
                {
                        pIndex = mArrayCount;
                }

                if (mArrayCount>= mBlockCount*mItemPerBlock) 
                {
                         // must allocate or reallocate block of items
                          mBlockCount++;
                          mArray = (Type *)FBRealloc( mArray,(size_t)(mBlockCount*mItemPerBlock*sizeof(Type)));
                }

                if (pIndex<mArrayCount) 
                {
                        // This is an insert
                        memmove (&(mArray[pIndex+1]),&(mArray[pIndex]),sizeof(Type)*(mArrayCount-pIndex));
                }

                mArray[pIndex] = pItem;
                mArrayCount++;

                return pIndex;
        }
void FBArrayTemplate< FBConstructionOperation * >::RemoveAt ( int  pIndex ) [inline, inherited]

Remove item at pIndex.

Parameters:
pIndex Index to remove item from.

Definition at line 142 of file fbarray.h.

        {
                assert( pIndex<mArrayCount );
                if (pIndex+1<mArrayCount) {
                        memmove (&(mArray[pIndex]),&(mArray[pIndex+1]),sizeof(Type)*(mArrayCount-pIndex-1));
                }
                mArrayCount --;
                memset (&(mArray[mArrayCount]),0,sizeof(Type)); // Cleanup last element to make sure we don't access it later
        }
void FBArrayTemplate< FBConstructionOperation * >::RemoveLast ( ) [inline, inherited]

Remove the last item in the array.

Definition at line 154 of file fbarray.h.

{ RemoveAt( mArrayCount-1 ); }  
bool FBArrayTemplate< FBConstructionOperation * >::Remove ( FBConstructionOperation * &  pItem ) [inline, inherited]

Remove pItem from the array.

Parameters:
pItem Item to remove.
Returns:
Operation was successful (true or false).

Definition at line 160 of file fbarray.h.

        {
          int Index = Find( pItem );
            if (Index>=0) {
                        RemoveAt( Index );
                        return true;
                }
                return false;
        }
bool FBArrayTemplate< FBConstructionOperation * >::RemoveIt ( FBConstructionOperation pItem ) [inline, inherited]

Remove pItem from the array.

Parameters:
pItem Item to remove.
Returns:
Outcome of removal (true or false).

Definition at line 174 of file fbarray.h.

        {
          int Index = Find( pItem );
            if (Index>=0) {
                        RemoveAt( Index );
                        return true;
                }
                return false;
        }
void FBArrayTemplate< FBConstructionOperation * >::Clear ( ) [inline, inherited]

Empty the array of all items.

Definition at line 185 of file fbarray.h.

        {
                if (mArray!=NULL) {
                        FBFree(mArray);
                        mArray = NULL;
                }
                mArrayCount  = 0L;
                mBlockCount  = 0L;
        }
FBConstructionOperation * & FBArrayTemplate< FBConstructionOperation * >::operator[] ( int  pIndex ) const [inline, inherited]

[] operator overload.

Parameters:
pIndex Index of item to access.
Returns:
Item corresponding to pIndex.

Definition at line 199 of file fbarray.h.

        {
                assert( pIndex<mArrayCount );
                return mArray[pIndex];
        }
void FBArrayTemplate< FBConstructionOperation * >::SetAt ( int  pIndex,
FBConstructionOperation pItem 
) [inline, inherited]

Set item at pIndex to pItem.

Parameters:
pIndex Index of item to set.
pItem Item to copy into the array.

Definition at line 209 of file fbarray.h.

        {
                assert( pIndex<mArrayCount );
                mArray[pIndex] = pItem;
        }
void FBArrayTemplate< FBConstructionOperation * >::SetLast ( FBConstructionOperation pItem ) [inline, inherited]

Set the last item of the array.

Parameters:
pItem Item to copy as the last item of the array
Warning:
Will write over last item in the array!

Definition at line 219 of file fbarray.h.

        { 
                SetAt(mArrayCount-1,pItem ); 
        }
int FBArrayTemplate< FBConstructionOperation * >::GetCount ( ) const [inline, inherited]

Get the number of items in the array.

Returns:
Number of items in the array.

Definition at line 227 of file fbarray.h.

        { 
                return mArrayCount; 
        }
void FBArrayTemplate< FBConstructionOperation * >::SetCount ( int  pCount ) [inline, inherited]

Set the number of items in the array.

Definition at line 234 of file fbarray.h.

        {
                if (pCount > mArrayCount)
                {
                        if( pCount )
                        {
                                const int lTempNewBlockCount = ( (int) (mArrayCount+pCount + mItemPerBlock - 1 ) / mItemPerBlock );
                                const int lNewBlockCount = (lTempNewBlockCount > 1 ? lTempNewBlockCount : 1);

                                const int lOldArraySize = mArrayCount*sizeof(Type);
                                const int lNewArraySize = lNewBlockCount*mItemPerBlock*sizeof(Type);

                                if( lNewBlockCount > (int) mBlockCount )
                                {                       
                                        mArray = (Type *)FBRealloc( mArray, (size_t) lNewArraySize );
                                        mBlockCount = lNewBlockCount;
                                }
                                
                                memset( ((char *)mArray) + lOldArraySize, 0, (size_t) (lNewArraySize-lOldArraySize) );
                                mArrayCount += pCount;
                        }
                } else 
                {
                        mArrayCount = pCount;
                }
        }
FBConstructionOperation * FBArrayTemplate< FBConstructionOperation * >::GetAt ( int  pIndex ) [inline, inherited]

Get item at pIndex.

Parameters:
pIndex Index of desired item.
Returns:
Item specified by pIndex.

Definition at line 265 of file fbarray.h.

        {               
                assert( pIndex<mArrayCount );
                return mArray[pIndex]; 
        }
FBConstructionOperation * FBArrayTemplate< FBConstructionOperation * >::GetLast ( ) [inline, inherited]

Get last item of the array.

Returns:
Last item of the array.

Definition at line 274 of file fbarray.h.

        { 
                return mArray[mArrayCount-1]; 
        }
int FBArrayTemplate< FBConstructionOperation * >::Find ( FBConstructionOperation pItem ) [inline, inherited]

Find the index of pItem in the array.

Parameters:
pItem Item to look for in the array.
Returns:
Index number of element found. Returns -1 if pItem was not found.

Definition at line 283 of file fbarray.h.

        {
          int Count;
                for (Count=0; Count<mArrayCount; Count++) {
                        if (mArray[Count]==pItem) {
                                return Count;
                        }
                }
                return -1;
        }
int FBArrayTemplate< FBConstructionOperation * >::Add ( FBConstructionOperation pItem ) [inline, inherited]

Add an item to the end of the array.

Parameters:
pItem Item to insert into the array.
Returns:
Index where pItem was inserted.

Definition at line 298 of file fbarray.h.

        { 
                return InsertAt( mArrayCount,pItem ); 
        }
FBConstructionOperation * * FBArrayTemplate< FBConstructionOperation * >::GetArray ( ) [inline, inherited]

Get a pointer to the array of items.

Returns:
Pointer to the array of items.
Warning:
Gives direct access to the array pointer!

Definition at line 307 of file fbarray.h.

        { 
                return mArray; 
        }

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