19 #if !defined(REUSABLEARENABLOCK_INCLUDE_GUARD_1357924680)
20 #define REUSABLEARENABLOCK_INCLUDE_GUARD_1357924680
35 template <
class ObjectType,
36 #if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
39 class SizeType =
unsigned short>
54 enum { VALID_OBJECT_STAMP = 0xffddffdd };
61 verificationStamp(VALID_OBJECT_STAMP)
68 return ( ( verificationStamp ==
int(VALID_OBJECT_STAMP)) &&
69 ( next <= rightBorder ) ) ? true : false ;
81 MemoryManager& theManager,
88 XALAN_STATIC_ASSERT(
sizeof(ObjectType) >=
sizeof(NextBlock));
90 for(
size_type i = 0; i < this->m_blockSize; ++i )
92 new (&this->m_objectBlock[i]) NextBlock(
size_type(i + 1));
101 i < this->m_blockSize &&
102 removedObjects < this->m_objectCount;
105 if ( isOccupiedBlock(&this->m_objectBlock[i]) )
107 this->m_objectBlock[i].~ObjectType();
116 MemoryManager& theManager,
137 if ( this->m_objectCount == this->m_blockSize )
139 assert ( this->m_firstFreeBlock == (this->m_blockSize + 1) );
145 assert( this->m_objectCount < this->m_blockSize );
147 ObjectType* theResult = 0;
149 assert ( this->m_firstFreeBlock <= this->m_blockSize );
150 assert ( this->m_nextFreeBlock <= this->m_blockSize );
153 if(this->m_firstFreeBlock != this->m_nextFreeBlock)
156 theResult = this->m_objectBlock + this->m_firstFreeBlock;
160 theResult = this->m_objectBlock + this->m_firstFreeBlock;
162 assert(
size_type(theResult - this->m_objectBlock) < this->m_blockSize);
164 NextBlock*
const theBlock =
165 reinterpret_cast<NextBlock*
>(theResult);
167 this->m_nextFreeBlock = theBlock->next;
169 assert(theBlock->isValidFor(this->m_blockSize));
170 assert(this->m_nextFreeBlock <= this->m_blockSize);
172 ++this->m_objectCount;
187 assert ( this->m_objectCount <= this->m_blockSize );
189 this->m_firstFreeBlock = this->m_nextFreeBlock;
202 assert(theObject != 0);
205 if ( this->m_firstFreeBlock != this->m_nextFreeBlock )
208 void*
const p = this->m_objectBlock + this->m_firstFreeBlock;
210 new (p) NextBlock(this->m_nextFreeBlock);
212 this->m_nextFreeBlock = this->m_firstFreeBlock;
215 assert(ownsObject(theObject) ==
true);
216 assert(shouldDestroyBlock(theObject));
220 new (theObject) NextBlock(this->m_firstFreeBlock);
223 this->m_nextFreeBlock =
224 size_type(theObject - this->m_objectBlock);
226 assert (this->m_firstFreeBlock <= this->m_blockSize);
228 --this->m_objectCount;
243 assert ( theObject != 0 );
245 return isOccupiedBlock(theObject);
262 assert(
size_type(theObject - this->m_objectBlock) < this->m_blockSize);
264 return !isOnFreeList(theObject);
272 return !(this->ownsBlock(block) &&
273 reinterpret_cast<const NextBlock*
>(block)->isValidFor(this->m_blockSize));
297 isOnFreeList(
const ObjectType* theObject)
const
299 if ( this->m_objectCount == 0 )
305 ObjectType* pRunPtr = this->m_objectBlock + this->m_firstFreeBlock;
308 i < this->m_blockSize - this->m_objectCount;
311 assert(this->ownsBlock(pRunPtr));
313 if (pRunPtr == theObject)
319 NextBlock*
const p =
reinterpret_cast<NextBlock*
>(pRunPtr);
321 assert(p->isValidFor(this->m_blockSize));
323 pRunPtr = this->m_objectBlock + p->next;
343 #endif // !defined(REUSABLEARENABLOCK_INCLUDE_GUARD_1357924680)