19 #if !defined(XALANVECTOR_HEADER_GUARD_1357924680)
20 #define XALANVECTOR_HEADER_GUARD_1357924680
48 #pragma warning(disable: 4100)
53 using xercesc::MemoryManager;
57 template <
class Type,
class ConstructionTraits = MemoryManagedConstructionTraits<Type> >
88 m_memoryManager(&theManager),
90 m_allocation(initialAllocation),
91 m_data(initialAllocation > 0 ? allocate(initialAllocation) : 0)
98 MemoryManager& theManager,
106 new (theGuard.
get())
ThisType(theManager, initialAllocation);
117 m_memoryManager(&theManager),
122 if (theSource.m_size > 0)
124 ThisType theTemp(theManager, local_max(theSource.m_size, theInitialAllocation));
131 else if (theInitialAllocation > 0)
133 m_data = allocate(theInitialAllocation);
135 m_allocation = theInitialAllocation;
142 const_iterator theFirst,
143 const_iterator theLast,
144 MemoryManager& theManager) :
145 m_memoryManager(&theManager),
153 theTemp.
insert(theTemp.
begin(), theFirst, theLast);
162 const_iterator theFirst,
163 const_iterator theLast,
164 MemoryManager& theManager)
171 new (theGuard.
get())
ThisType(theFirst, theLast, theManager);
181 MemoryManager& theManager) :
182 m_memoryManager(&theManager),
189 theTemp.
insert(theTemp.
begin(), theInsertSize, theData);
200 if (m_allocation != 0)
202 destroy(begin(), end());
225 destroy(m_data[m_size]);
237 if (theFirst != theLast)
244 shrinkCount(local_distance(theFirst, theLast));
255 return erase(position, position + 1);
261 const_iterator theFirst,
262 const_iterator theLast)
266 assert(theFirst <= theLast);
267 assert(thePosition >= begin());
268 assert(thePosition <= end());
273 local_distance(theFirst, theLast);
275 if (theInsertSize == 0)
280 const size_type theTotalSize = size() + theInsertSize;
282 if (thePosition == end())
284 pointer thePointer = ensureCapacity(theTotalSize);
286 while (theFirst != theLast)
288 Constructor::construct(thePointer, *theFirst, *m_memoryManager);
297 if (theTotalSize > capacity())
299 assert (m_memoryManager != 0);
301 ThisType theTemp(*m_memoryManager, theTotalSize);
304 theTemp.
insert(theTemp.
end(), begin(), thePosition);
307 theTemp.
insert(theTemp.
end(), theFirst, theLast);
310 theTemp.
insert(theTemp.
end(), thePosition, end());
317 const iterator theOriginalEnd = end();
320 local_distance(thePosition, theOriginalEnd);
322 if (theRightSplitSize <= theInsertSize)
328 const const_iterator toInsertSplit = theFirst + theRightSplitSize;
329 const_iterator toInsertIter = toInsertSplit;
331 while (toInsertIter != theLast)
333 doPushBack(*toInsertIter);
339 toInsertIter = thePosition;
340 while (toInsertIter != theOriginalEnd)
342 doPushBack(*toInsertIter);
349 std::copy(theFirst, toInsertSplit, thePosition);
356 const_iterator toMoveIter = end() - theInsertSize;
358 while (toMoveIter != theOriginalEnd)
360 doPushBack(*toMoveIter);
366 std::copy_backward(thePosition, theOriginalEnd - theInsertSize, theOriginalEnd);
369 std::copy(theFirst, theLast, thePosition);
385 const size_type theTotalSize = size() + theCount;
388 if (thePosition == end())
390 pointer thePointer = ensureCapacity(theTotalSize);
392 for (
size_type index = 0; index < theCount; ++index)
394 Constructor::construct(thePointer, theData, *m_memoryManager);
402 if (theTotalSize > capacity())
404 assert ( m_memoryManager != 0 );
406 ThisType theTemp(*m_memoryManager, theTotalSize);
409 theTemp.
insert(theTemp.
end(), begin(), thePosition);
412 theTemp.
insert(theTemp.
end(), theCount, theData);
415 theTemp.
insert(theTemp.
end(), thePosition, end());
422 const iterator theOriginalEnd = end();
425 local_distance(thePosition, theOriginalEnd);
427 if (theRightSplitSize <= theCount)
433 for (
size_type i = 0; i < (theCount - theRightSplitSize); ++i)
439 iterator toInsertIter = thePosition;
441 while (toInsertIter != theOriginalEnd)
443 doPushBack(*toInsertIter);
450 std::fill(thePosition, thePosition + theRightSplitSize, theData);
457 const_iterator toMoveIter = end() - theCount;
459 while (toMoveIter != theOriginalEnd)
461 doPushBack(*toMoveIter);
467 std::copy_backward(thePosition, theOriginalEnd - theCount, theOriginalEnd);
470 std::fill(thePosition, thePosition + theCount, theData);
483 if (m_allocation > m_size)
485 insert(thePosition, 1, theData);
492 local_distance(begin(), thePosition);
494 insert(thePosition, 1, theData);
496 return begin() + theDistance;
502 const_iterator theFirst,
503 const_iterator theLast)
519 const_iterator(theFirst),
520 const_iterator(theLast));
530 insert(theCount, theData);
554 resize(theSize, defaultValue.value);
564 if (m_size > theSize)
566 shrinkToSize(theSize);
568 else if (m_size < theSize)
573 assert(m_allocation >= theSize);
575 const value_type*
const theEnd = m_data + theSize;
582 Constructor::construct(data, theValue, *m_memoryManager);
586 assert(m_size == theSize);
604 return m_size == 0 ? true :
false;
612 if (theSize > m_allocation)
639 return m_data[m_size - 1];
645 return m_data[m_size - 1];
688 const_reverse_iterator
704 const_reverse_iterator
716 if (theIndex >= m_size)
721 return m_data[theIndex];
727 if (theIndex >= m_size)
732 return m_data[theIndex];
738 assert (theIndex < m_size);
740 return m_data[theIndex];
746 assert (theIndex < m_size);
748 return m_data[theIndex];
772 if (m_allocation < theRHS.m_size)
774 ThisType theTemp(theRHS,*m_memoryManager);
780 const_iterator theRHSCopyEnd = theRHS.
end();
782 if (m_size > theRHS.m_size)
785 shrinkToSize(theRHS.m_size);
787 else if (m_size < theRHS.m_size)
792 theRHS.
begin() + m_size;
818 MemoryManager*
const theTempManager = m_memoryManager;
820 const size_type theTempAllocation = m_allocation;
823 m_memoryManager = theOther.m_memoryManager;
824 m_size = theOther.m_size;
825 m_allocation = theOther.m_allocation;
826 m_data = theOther.m_data;
828 theOther.m_memoryManager = theTempManager;
829 theOther.m_size = theTempLength;
830 theOther.m_allocation = theTempAllocation;
831 theOther.m_data = theTempData;
839 assert (m_memoryManager != 0);
841 return *m_memoryManager;
847 assert (m_memoryManager != 0);
849 return *m_memoryManager;
880 assert(m_allocation >= m_size);
882 (m_data == 0 && m_allocation == 0) ||
883 (m_data != 0 && m_allocation != 0));
889 const_iterator theFirst,
890 const_iterator theLast)
894 assert(theFirst <= theLast);
896 return std::distance(theFirst, theLast);
902 const size_type theBytesNeeded = size *
sizeof(value_type);
904 assert (m_memoryManager != 0);
906 void* pointer = m_memoryManager->allocate(theBytesNeeded);
908 assert(pointer != 0);
910 return (value_type*) pointer;
914 deallocate(value_type* pointer)
916 assert(m_memoryManager != 0);
918 m_memoryManager->deallocate(pointer);
923 destroy(value_type& theValue)
933 for(; theFirst != theLast; ++theFirst)
940 grow(
const value_type& data)
944 assert(m_size != 0 && m_size == m_allocation);
947 assert(theNewSize > m_size);
949 ThisType theTemp(*
this, *m_memoryManager, theNewSize);
951 theTemp.doPushBack(data);
959 construct_back(
const value_type& data)
963 assert(m_size < m_allocation);
965 Constructor::construct(
976 init(
const value_type& data)
980 assert(m_size == 0 && m_allocation == 0);
982 m_data = allocate(1);
986 construct_back(data);
992 doPushBack(
const value_type& data)
996 if (m_size < m_allocation)
998 construct_back(data);
1000 else if (m_size == 0)
1015 if (theSize > capacity())
1020 return endPointer();
1028 assert(theSize > m_allocation);
1030 ThisType theTemp(*
this, *m_memoryManager, theSize);
1040 return m_data + m_size;
1046 return m_data + m_size;
1052 throw std::out_of_range(
"");
1058 assert(m_size > theSize);
1063 }
while (m_size > theSize);
1069 assert(m_size >= theCount);
1071 while (theCount > 0)
1084 return theLHS > theRHS ? theLHS : theRHS;
1087 #if defined(XALAN_DEVELOPMENT)
1089 XalanVector(
const XalanVector&);
1094 MemoryManager* m_memoryManager;
1105 template <
class Type>
1111 theLHS.
swap(theRHS);
1116 template <
class Type>
1122 if (theLHS.
size() != theRHS.
size())
1126 else if (theLHS.
size() == 0)
1132 return std::equal(theLHS.
begin(), theLHS.
end(), theRHS.
begin());
1138 template <
class Type>
1144 return !(theLHS == theRHS);
1149 template <
class Type>
1155 return std::lexicographical_compare(
1164 template <
class Type>
1170 return !(theRHS < theLHS);
1175 template <
class Type>
1181 return theRHS < theLHS;
1186 template <
class Type>
1192 return !(theLHS < theRHS);
1197 #if defined(_MSC_VER)
1198 #pragma warning(pop)
1207 #endif // XALANVECTOR_HEADER_GUARD_1357924680