19 #if !defined(ARENABLOCKBASE_INCLUDE_GUARD_1357924680) 20 #define ARENABLOCKBASE_INCLUDE_GUARD_1357924680 30 #if !defined(XALAN_NO_SELECTIVE_TEMPLATE_INSTANTIATION) 38 #if defined(XALAN_NO_SELECTIVE_TEMPLATE_INSTANTIATION) 41 class ArenaBlockAllocator
46 typedef ptrdiff_t difference_type;
47 typedef Type* pointer;
48 typedef const Type* const_pointer;
49 typedef Type& reference;
50 typedef const Type& const_reference;
51 typedef Type value_type;
53 ArenaBlockAllocator(MemoryManager& theManager) :
54 m_memoryManager(theManager)
58 ~ArenaBlockAllocator()
65 return m_memoryManager;
73 return (pointer)m_memoryManager.allocate(size *
sizeof(Type));
83 m_memoryManager.deallocate(p);
90 ArenaBlockAllocator(
const ArenaBlockAllocator<Type>&);
92 ArenaBlockAllocator<Type>&
93 operator=(
const ArenaBlockAllocator<Type>&);
95 MemoryManager& m_memoryManager;
101 template<
class ObjectType,
102 #if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS) 105 class SizeType =
size_t>
113 #if defined(XALAN_NO_SELECTIVE_TEMPLATE_INSTANTIATION) 124 return m_allocator.getMemoryManager();
135 return m_objectCount < m_blockSize ? true :
false;
146 return m_objectCount == 0 ? true :
false;
158 return m_objectCount;
184 return isInBorders(theObject, m_blockSize);
190 MemoryManager& theManager,
192 m_allocator(theManager),
194 m_blockSize(theBlockSize),
195 m_objectBlock(m_allocator.allocate(m_blockSize))
197 assert(theBlockSize > 0);
199 assert(m_objectBlock != 0);
205 m_allocator.deallocate(m_objectBlock, m_blockSize);
218 const ObjectType* theObject,
221 if ( rightBoundary > m_blockSize )
223 rightBoundary = m_blockSize;
228 std::less<const ObjectType*> functor;
230 if (functor(theObject, m_objectBlock) ==
false &&
231 functor(theObject, m_objectBlock + rightBoundary) ==
true)
252 assert(
size_type( (theObject - m_objectBlock) /
sizeof(ObjectType) ) < m_blockSize);
254 return theObject - m_objectBlock;
269 assert(theOffset < m_blockSize);
271 return m_objectBlock + theOffset;
299 #endif // !defined(ARENABLOCKBASE_INCLUDE_GUARD_1357924680)
bool ownsBlock(const ObjectType *theObject) const
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
MemoryManager & getMemoryManager()
size_type getCountAllocated() const
ArenaBlockBase(MemoryManager &theManager, size_type theBlockSize)
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
ObjectType * m_objectBlock
XalanAllocator< ObjectType > AllocatorType
ArenaBlockBase< ObjectType, SizeType > ThisType
bool blockAvailable() const
const size_type m_blockSize
size_type getBlockSize() const
bool isInBorders(const ObjectType *theObject, size_type rightBoundary) const
ObjectType * getBlockAddress(size_type theOffset) const
AllocatorType m_allocator
size_type getBlockOffset(const ObjectType *theObject) const