#ifndef _COMMON_BLOCK_TPP_ #define _COMMON_BLOCK_TPP_ template void Block::remove(void) { if(!mContainer)return; Container *Cursor=mContainer; Container *Thumb; while(Cursor) { Thumb=Cursor; Cursor=Cursor->next(); ::delete Thumb; } mContainer=0; mLastIndexReferenced=-1L; mLastObjectReferenced=0; mLastObjectInserted=0; mSize=0; } template T &Block::find(LONG itemIndex) { Container *lpCursor=mContainer; Index i=0; for(i=0;inext(); if(i==itemIndex) { mLastIndexReferenced=i; mLastObjectReferenced=lpCursor; return *lpCursor->mItem; } return *((T*)0); } template Block &Block::operator+=(const Block &someBlock) { size_t blockSize(someBlock.size()); if(!blockSize)return *this; for(int itemIndex=0;itemIndex&)someBlock)[itemIndex]); return *this; } template bool Block::insertAfter(Index itemIndex,const T *item) { if(itemIndex>=mSize)return false; mLastObjectInserted->next(::new Container); mLastObjectInserted->next()->prev(mLastObjectInserted); mLastObjectInserted=mLastObjectInserted->next(); mLastObjectInserted->mItem=::new T(); mSize++; for(int index=mSize-1;index>itemIndex+1;index--) { operator[](index)=operator[](index-1); } operator[](itemIndex+1)=*item; return true; } template void Block::insert(Block &newBlock) { LONG size(newBlock.size()); for(Index i=0;i void Block::insert(const T& item) { insert(&item); } template void Block::insert(const T *item) { if(!mContainer) { mContainer=::new Container; mContainer->mItem=::new T(*item); mLastObjectInserted=mContainer; mSize++; } else { mLastObjectInserted->next(::new Container); mLastObjectInserted->next()->prev(mLastObjectInserted); mLastObjectInserted=mLastObjectInserted->next(); mLastObjectInserted->mItem=::new T(*item); mSize++; } } template void Block::remove(Block &removeBlock) { LONG size(removeBlock.size()); if(!size)return; for(long itemIndex=size-1;itemIndex>=0;itemIndex--)remove(&removeBlock[itemIndex]); } template void Block::remove(const T *item) { Container *lpThumb=mContainer; if(!lpThumb)return; if(*item==*(mLastObjectInserted->mItem))lpThumb=mLastObjectInserted; else while(lpThumb){if(*item==*(lpThumb->mItem))break;lpThumb=lpThumb->next();} if(!lpThumb)return; if(lpThumb==mContainer) { if(lpThumb->next()){mContainer=lpThumb->next();mContainer->prev(0);} else {mContainer=0;mLastObjectInserted=0;} } else { if(lpThumb->next()){lpThumb->prev()->next(lpThumb->next());lpThumb->next()->prev(lpThumb->prev());} else {lpThumb->prev()->next(0);mLastObjectInserted=lpThumb->prev();} } ::delete lpThumb; mSize--; mLastIndexReferenced=-1; mLastObjectReferenced=0; } template void Block::remove(LONG itemIndex) { Container *lpThumb=mContainer; if(!lpThumb||itemIndex>=mSize)return; if(itemIndex==mSize-1)lpThumb=mLastObjectInserted; else { for(Index i=0;inext(); } if(!lpThumb)return; } if(lpThumb==mContainer) { if(lpThumb->next()){mContainer=lpThumb->next();mContainer->prev(0);} else {mContainer=0;mLastObjectInserted=0;} } else { if(lpThumb->next()){lpThumb->prev()->next(lpThumb->next());lpThumb->next()->prev(lpThumb->prev());} else {lpThumb->prev()->next(0);mLastObjectInserted=lpThumb->prev();} } ::delete lpThumb; mSize--; mLastIndexReferenced=-1; mLastObjectReferenced=0; } template Block &Block::operator=(const Block &someBlock) { LONG itemCount(someBlock.size()); remove(); if(!itemCount)return *this; for(LONG itemIndex=0;itemIndex&)someBlock)[itemIndex])); return *this; } template WORD Block::operator==(const Block &someBlock)const { LONG itemCount(size()); if(itemCount!=someBlock.size())return FALSE; for(LONG itemIndex=0;itemIndex&)*this).operator[](itemIndex)==((Block&)someBlock)[itemIndex]))return FALSE; return TRUE; } #endif