16 #if !defined(XALANARRAYALLOCATOR_HEADER_GUARD_1357924680)
17 #define XALANARRAYALLOCATOR_HEADER_GUARD_1357924680
35 XALAN_CPP_NAMESPACE_BEGIN
47 typedef XALAN_STD_QUALIFIER pair<size_type, VectorType * >
ListEntryType;
55 enum { eDefaultBlockSize = 500 };
63 size_type theBlockSize = eDefaultBlockSize) :
65 m_blockSize(theBlockSize),
76 for( iter = m_list.begin(); iter != m_list.end(); ++iter)
78 if( (*iter).second != 0)
80 #if defined(XALAN_REQUIRES_QUALIFIED_DESTRUCTOR)
81 (*iter).second->VectorType::~VectorType();
83 (*iter).second->~VectorType();
85 theManager.deallocate((
void*)(*iter).second);
109 if (m_list.empty() ==
true)
111 m_lastEntryFound = 0;
120 (*theCurrent).first = (*theCurrent).second->size();
123 }
while(theCurrent != theEnd);
125 m_lastEntryFound = &*m_list.begin();
139 if (theCount >= m_blockSize)
141 return createEntry(theCount, theCount);
152 return createEntry(m_blockSize, theCount);
158 assert( theEntry->second != 0);
159 Type*
const thePointer =
160 &*theEntry->second->begin() + (theEntry->second->size() - theEntry->first);
163 theEntry->first -= theCount;
178 assert(theBlockSize >= theCount);
182 m_list.push_back(ListEntryType(0, VectorType::create(m_list.getMemoryManager())));
185 ListEntryType& theNewEntry = m_list.back();
188 assert(theNewEntry.second);
190 theNewEntry.second->resize(theBlockSize, value_type());
193 theNewEntry.first = theBlockSize - theCount;
195 if (theNewEntry.first != 0)
197 m_lastEntryFound = &theNewEntry;
201 return &*theNewEntry.second->begin();
209 if (m_lastEntryFound != 0 && m_lastEntryFound->first >= theCount)
211 return m_lastEntryFound;
215 const ListIteratorType theEnd = m_list.end();
216 ListIteratorType theCurrent = m_list.begin();
218 ListEntryType* theEntry = 0;
220 while(theCurrent != theEnd)
226 if ((*theCurrent).first == theCount)
228 theEntry = &*theCurrent;
232 else if ((*theCurrent).first >= theCount)
242 (*theCurrent).first < theEntry->first)
245 theEntry = &*theCurrent;
257 m_lastEntryFound = theEntry;
278 ListEntryType* m_lastEntryFound;
283 XALAN_CPP_NAMESPACE_END
287 #endif // !defined(XALANARRAYALLOCATOR_HEADER_GUARD_1357924680)
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1111
~XalanArrayAllocator()
Definition: XalanArrayAllocator.hpp:70
VectorType::size_type size_type
Definition: XalanArrayAllocator.hpp:45
XalanList< ListEntryType > ListType
Definition: XalanArrayAllocator.hpp:48
XALAN_CPP_NAMESPACE_BEGIN typedef XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager MemoryManagerType
Definition: XalanMemoryManagement.hpp:39
ListType::iterator ListIteratorType
Definition: XalanArrayAllocator.hpp:52
void clear()
Clear the instance, and release all allocated memory.
Definition: XalanArrayAllocator.hpp:94
Type value_type
Definition: XalanArrayAllocator.hpp:50
XALAN_CPP_NAMESPACE_BEGIN typedef size_t size_type
Definition: XalanMap.hpp:44
XalanArrayAllocator(MemoryManagerType &theManager, size_type theBlockSize=eDefaultBlockSize)
Constructor.
Definition: XalanArrayAllocator.hpp:62
XALAN_STD_QUALIFIER pair< size_type, VectorType * > ListEntryType
Definition: XalanArrayAllocator.hpp:47
Definition: XalanArrayAllocator.hpp:40
XalanVector< Type > VectorType
Definition: XalanArrayAllocator.hpp:44
size_t size_type
Definition: XalanVector.hpp:71
Definition: XalanList.hpp:65
Definition: XalanVector.hpp:61
void reset()
Reset the instance, but keep all memory so it can be reused for allocations.
Definition: XalanArrayAllocator.hpp:107
Type * allocate(size_type theCount)
Allocate slots for the given number of Types instance and return the address of the slots...
Definition: XalanArrayAllocator.hpp:136