18 #if !defined(XALANARRAYALLOCATOR_HEADER_GUARD_1357924680) 19 #define XALANARRAYALLOCATOR_HEADER_GUARD_1357924680 37 XALAN_CPP_NAMESPACE_BEGIN
49 typedef XALAN_STD_QUALIFIER pair<size_type, VectorType * >
ListEntryType;
57 enum { eDefaultBlockSize = 500 };
65 size_type theBlockSize = eDefaultBlockSize) :
67 m_blockSize(theBlockSize),
76 MemoryManager& theManager = m_list.getMemoryManager();
78 for( iter = m_list.begin(); iter != m_list.end(); ++iter)
80 if( (*iter).second != 0)
82 #if defined(XALAN_REQUIRES_QUALIFIED_DESTRUCTOR) 83 (*iter).second->VectorType::~VectorType();
85 (*iter).second->~VectorType();
87 theManager.deallocate((
void*)(*iter).second);
100 m_lastEntryFound = 0;
111 if (m_list.empty() ==
true)
113 m_lastEntryFound = 0;
117 const ListIteratorType theEnd = m_list.end();
118 ListIteratorType theCurrent = m_list.begin();
122 (*theCurrent).first = (*theCurrent).second->size();
125 }
while(theCurrent != theEnd);
127 m_lastEntryFound = &*m_list.begin();
141 if (theCount >= m_blockSize)
143 return createEntry(theCount, theCount);
147 ListEntryType* theEntry =
154 return createEntry(m_blockSize, theCount);
160 assert( theEntry->second != 0);
161 Type*
const thePointer =
162 &*theEntry->second->begin() + (theEntry->second->size() - theEntry->first);
165 theEntry->first -= theCount;
177 size_type theBlockSize,
180 assert(theBlockSize >= theCount);
184 m_list.push_back(ListEntryType(0, VectorType::create(m_list.getMemoryManager())));
187 ListEntryType& theNewEntry = m_list.back();
190 assert(theNewEntry.second);
192 theNewEntry.second->resize(theBlockSize, value_type());
195 theNewEntry.first = theBlockSize - theCount;
197 if (theNewEntry.first != 0)
199 m_lastEntryFound = &theNewEntry;
203 return &*theNewEntry.second->begin();
207 findEntry(size_type theCount)
211 if (m_lastEntryFound != 0 && m_lastEntryFound->first >= theCount)
213 return m_lastEntryFound;
217 const ListIteratorType theEnd = m_list.end();
218 ListIteratorType theCurrent = m_list.begin();
220 ListEntryType* theEntry = 0;
222 while(theCurrent != theEnd)
228 if ((*theCurrent).first == theCount)
230 theEntry = &*theCurrent;
234 else if ((*theCurrent).first >= theCount)
244 (*theCurrent).first < theEntry->first)
247 theEntry = &*theCurrent;
259 m_lastEntryFound = theEntry;
278 const size_type m_blockSize;
280 ListEntryType* m_lastEntryFound;
285 XALAN_CPP_NAMESPACE_END
289 #endif // !defined(XALANARRAYALLOCATOR_HEADER_GUARD_1357924680)
VectorType::size_type size_type
XalanList< ListEntryType > ListType
ListType::iterator ListIteratorType
void clear()
Clear the instance, and release all allocated memory.
XalanArrayAllocator(MemoryManager &theManager, size_type theBlockSize=eDefaultBlockSize)
Constructor.
XALAN_STD_QUALIFIER pair< size_type, VectorType *> ListEntryType
XalanVector< Type > VectorType
bool operator==(const ElemAttributeSet &theLHS, const ElemAttributeSet &theRHS)
void reset()
Reset the instance, but keep all memory so it can be reused for allocations.
Type * allocate(size_type theCount)
Allocate slots for the given number of Types instance and return the address of the slots...