19 #if !defined(XALANDEQUE_HEADER_GUARD_1357924680)
20 #define XALANDEQUE_HEADER_GUARD_1357924680
38 template <
class Value>
47 template <
class Value>
56 template <
class Traits,
class XalanDeque>
91 m_deque(iterator.m_deque),
103 m_deque = iterator.m_deque;
104 m_pos = iterator.m_pos;
137 return &(*m_deque[m_pos]);
143 return (*m_deque)[m_pos];
149 return (*m_deque)[m_pos];
167 return m_pos - theRHS.m_pos;
173 return theRHS.m_deque == m_deque &&
174 theRHS.m_pos == m_pos;
180 return !(theRHS == *
this);
186 return m_pos < theRHS.m_pos;
199 template <
class Type,
class ConstructionTraits = MemoryManagedConstructionTraits<Type> >
228 MemoryManager& memoryManager,
231 m_memoryManager(&memoryManager),
232 m_blockSize(blockSize),
233 m_blockIndex(memoryManager,
234 initialSize / blockSize + (initialSize % blockSize == 0 ? 0 : 1)),
235 m_freeBlockVector(memoryManager)
240 using std::back_inserter;
243 back_inserter(*
this),
250 MemoryManager& theMemoryManager) :
251 m_memoryManager(&theMemoryManager),
252 m_blockSize(theRHS.m_blockSize),
253 m_blockIndex(*theRHS.m_memoryManager,
254 theRHS.size() / theRHS.m_blockSize + (theRHS.size() % theRHS.m_blockSize == 0 ? 0 : 1)),
255 m_freeBlockVector(theMemoryManager)
258 using std::back_inserter;
263 back_inserter(*
this));
268 MemoryManager& theManager,
275 new (theGuard.
get())
ThisType(theManager, initialSize, blockSize);
284 destroyBlockList(m_freeBlockVector);
286 destroyBlockList(m_blockIndex);
313 const_reverse_iterator
319 const_reverse_iterator
328 return m_blockIndex.empty();
334 if (m_blockIndex.empty())
340 return (m_blockIndex.size() - 1) * m_blockSize
341 + m_blockIndex.back()->size();
348 return m_blockIndex.back()->back();
354 BlockType& block = *m_blockIndex[index / m_blockSize];
356 return block[index % m_blockSize];
362 BlockType& block = *m_blockIndex[index / m_blockSize];
364 return block[index % m_blockSize];
372 m_freeBlockVector.reserve(m_freeBlockVector.size() + m_blockIndex.size());
374 while (iter != m_blockIndex.end())
377 m_freeBlockVector.push_back(*iter);
381 m_blockIndex.clear();
387 if (m_blockIndex.empty() ||
388 m_blockIndex.back()->size() >= m_blockSize)
393 m_blockIndex.back()->push_back(value);
404 if (lastBlock.
empty())
406 m_freeBlockVector.push_back(&lastBlock);
407 m_blockIndex.pop_back();
416 if (newSize > size())
418 for (
size_type i = 0; i < newSize - size(); ++i)
420 push_back(defaultValue.value);
425 for (
size_type i = 0; i < size() - newSize; ++i)
435 MemoryManager*
const temp = m_memoryManager;
436 m_memoryManager = theRHS.m_memoryManager;
437 theRHS.m_memoryManager = temp;
439 theRHS.m_blockIndex.
swap(m_blockIndex);
440 theRHS.m_freeBlockVector.
swap(m_freeBlockVector);
449 using std::back_inserter;
456 back_inserter(*
this));
465 assert (m_memoryManager != 0);
467 return *m_memoryManager;
478 m_blockIndex.push_back(0);
480 if (m_freeBlockVector.empty())
490 m_blockIndex.back() = m_freeBlockVector.back();
494 m_freeBlockVector.pop_back();
497 assert(m_blockIndex.back() != 0);
501 destroyBlockList(BlockIndexType& theBlockIndex)
503 typename BlockIndexType::iterator iter =
504 theBlockIndex.begin();
506 while (iter != theBlockIndex.end())
522 MemoryManager* m_memoryManager;
526 BlockIndexType m_blockIndex;
527 BlockIndexType m_freeBlockVector;
533 XalanDeque(
const XalanDeque&);
542 #endif // XALANDEQUE_HEADER_GUARD_1357924680