19 #if !defined(XALANVECTOR_HEADER_GUARD_1357924680)
20 #define XALANVECTOR_HEADER_GUARD_1357924680
42 XALAN_CPP_NAMESPACE_BEGIN
48 #pragma warning(disable: 4100)
57 template <
class Type,
class ConstructionTraits = MemoryManagedConstructionTraits<Type> >
71 #if defined(XALAN_VCPP_USE_PTRIT)
92 #if defined(XALAN_HAS_STD_ITERATORS)
95 #elif defined(XALAN_RW_NO_CLASS_PARTIAL_SPEC)
96 typedef XALAN_STD_QUALIFIER random_access_iterator_tag iterator_category;
128 m_memoryManager(&theManager),
130 m_allocation(initialAllocation),
131 m_data(initialAllocation > 0 ? allocate(initialAllocation) : 0)
138 MemoryManager& theManager,
146 new (theGuard.
get())
ThisType(theManager, initialAllocation);
157 m_memoryManager(&theManager),
162 if (theSource.m_size > 0)
164 ThisType theTemp(theManager, local_max(theSource.m_size, theInitialAllocation));
171 else if (theInitialAllocation > 0)
173 m_data = allocate(theInitialAllocation);
175 m_allocation = theInitialAllocation;
184 MemoryManager& theManager) :
185 m_memoryManager(&theManager),
193 theTemp.
insert(theTemp.
begin(), theFirst, theLast);
204 MemoryManager& theManager)
211 new (theGuard.
get())
ThisType(theFirst, theLast, theManager);
221 MemoryManager& theManager) :
222 m_memoryManager(&theManager),
229 theTemp.
insert(theTemp.
begin(), theInsertSize, theData);
240 if (m_allocation != 0)
265 destroy(m_data[m_size]);
277 if (theFirst != theLast)
279 XALAN_STD_QUALIFIER copy(
284 shrinkCount(local_distance(theFirst, theLast));
295 return erase(position, position + 1);
306 assert(theFirst <= theLast);
307 assert(thePosition >=
begin());
308 assert(thePosition <=
end());
313 local_distance(theFirst, theLast);
315 if (theInsertSize == 0)
322 if (thePosition ==
end())
324 pointer thePointer = ensureCapacity(theTotalSize);
326 while (theFirst != theLast)
328 Constructor::construct(thePointer, *theFirst, *m_memoryManager);
339 assert (m_memoryManager != 0);
341 ThisType theTemp(*m_memoryManager, theTotalSize);
347 theTemp.
insert(theTemp.
end(), theFirst, theLast);
360 local_distance(thePosition, theOriginalEnd);
362 if (theRightSplitSize <= theInsertSize)
368 const const_iterator toInsertSplit = theFirst + theRightSplitSize;
371 while (toInsertIter != theLast)
373 doPushBack(*toInsertIter);
379 toInsertIter = thePosition;
380 while (toInsertIter != theOriginalEnd)
382 doPushBack(*toInsertIter);
389 XALAN_STD_QUALIFIER copy(theFirst, toInsertSplit, thePosition);
398 while (toMoveIter != theOriginalEnd)
400 doPushBack(*toMoveIter);
406 XALAN_STD_QUALIFIER copy_backward(thePosition, theOriginalEnd - theInsertSize, theOriginalEnd);
409 XALAN_STD_QUALIFIER copy(theFirst, theLast, thePosition);
428 if (thePosition ==
end())
430 pointer thePointer = ensureCapacity(theTotalSize);
432 for (
size_type index = 0; index < theCount; ++index)
434 Constructor::construct(thePointer, theData, *m_memoryManager);
444 assert ( m_memoryManager != 0 );
446 ThisType theTemp(*m_memoryManager, theTotalSize);
452 theTemp.
insert(theTemp.
end(), theCount, theData);
465 local_distance(thePosition, theOriginalEnd);
467 if (theRightSplitSize <= theCount)
473 for (
size_type i = 0; i < (theCount - theRightSplitSize); ++i)
479 iterator toInsertIter = thePosition;
481 while (toInsertIter != theOriginalEnd)
483 doPushBack(*toInsertIter);
490 XALAN_STD_QUALIFIER fill(thePosition, thePosition + theRightSplitSize, theData);
499 while (toMoveIter != theOriginalEnd)
501 doPushBack(*toMoveIter);
507 XALAN_STD_QUALIFIER copy_backward(thePosition, theOriginalEnd - theCount, theOriginalEnd);
510 XALAN_STD_QUALIFIER fill(thePosition, thePosition + theCount, theData);
523 if (m_allocation > m_size)
525 insert(thePosition, 1, theData);
532 local_distance(
begin(), thePosition);
534 insert(thePosition, 1, theData);
536 return begin() + theDistance;
570 insert(theCount, theData);
594 resize(theSize, defaultValue.value);
604 if (m_size > theSize)
606 shrinkToSize(theSize);
608 else if (m_size < theSize)
613 assert(m_allocation >= theSize);
615 const value_type*
const theEnd = m_data + theSize;
622 Constructor::construct(data, theValue, *m_memoryManager);
626 assert(m_size == theSize);
644 return m_size == 0 ? true :
false;
652 if (theSize > m_allocation)
679 return m_data[m_size - 1];
685 return m_data[m_size - 1];
756 if (theIndex >= m_size)
761 return m_data[theIndex];
767 if (theIndex >= m_size)
772 return m_data[theIndex];
778 assert (theIndex < m_size);
780 return m_data[theIndex];
786 assert (theIndex < m_size);
788 return m_data[theIndex];
812 if (m_allocation < theRHS.m_size)
814 ThisType theTemp(theRHS,*m_memoryManager);
822 if (m_size > theRHS.m_size)
825 shrinkToSize(theRHS.m_size);
827 else if (m_size < theRHS.m_size)
832 theRHS.
begin() + m_size;
841 XALAN_STD_QUALIFIER copy(
858 MemoryManager*
const theTempManager = m_memoryManager;
860 const size_type theTempAllocation = m_allocation;
863 m_memoryManager = theOther.m_memoryManager;
864 m_size = theOther.m_size;
865 m_allocation = theOther.m_allocation;
866 m_data = theOther.m_data;
868 theOther.m_memoryManager = theTempManager;
869 theOther.m_size = theTempLength;
870 theOther.m_allocation = theTempAllocation;
871 theOther.m_data = theTempData;
879 assert (m_memoryManager != 0);
881 return *m_memoryManager;
887 assert (m_memoryManager != 0);
889 return *m_memoryManager;
920 assert(m_allocation >= m_size);
922 (m_data == 0 && m_allocation == 0) ||
923 (m_data != 0 && m_allocation != 0));
934 assert(theFirst <= theLast);
936 #if defined(XALAN_HAS_STD_DISTANCE)
937 return XALAN_STD_QUALIFIER distance(theFirst, theLast);
941 XALAN_STD_QUALIFIER distance(theFirst, theLast, theDistance);
952 assert (m_memoryManager != 0);
954 void*
pointer = m_memoryManager->allocate(theBytesNeeded);
964 assert(m_memoryManager != 0);
966 m_memoryManager->deallocate(
pointer);
981 for(; theFirst != theLast; ++theFirst)
992 assert(m_size != 0 && m_size == m_allocation);
995 assert(theNewSize > m_size);
997 ThisType theTemp(*
this, *m_memoryManager, theNewSize);
999 theTemp.doPushBack(data);
1011 assert(m_size < m_allocation);
1013 Constructor::construct(
1028 assert(m_size == 0 && m_allocation == 0);
1030 m_data = allocate(1);
1034 construct_back(data);
1044 if (m_size < m_allocation)
1046 construct_back(data);
1048 else if (m_size == 0)
1068 return endPointer();
1076 assert(theSize > m_allocation);
1078 ThisType theTemp(*
this, *m_memoryManager, theSize);
1088 return m_data + m_size;
1094 return m_data + m_size;
1100 throw XALAN_STD_QUALIFIER out_of_range(
"");
1106 assert(m_size > theSize);
1111 }
while (m_size > theSize);
1117 assert(m_size >= theCount);
1119 while (theCount > 0)
1132 return theLHS > theRHS ? theLHS : theRHS;
1135 #if defined(XALAN_DEVELOPMENT)
1142 MemoryManager* m_memoryManager;
1153 template <
class Type>
1159 theLHS.
swap(theRHS);
1164 template <
class Type>
1170 if (theLHS.
size() != theRHS.
size())
1174 else if (theLHS.
size() == 0)
1180 return XALAN_STD_QUALIFIER equal(theLHS.
begin(), theLHS.
end(), theRHS.
begin());
1186 template <
class Type>
1192 return !(theLHS == theRHS);
1197 template <
class Type>
1203 return XALAN_STD_QUALIFIER lexicographical_compare(
1212 template <
class Type>
1218 return !(theRHS < theLHS);
1223 template <
class Type>
1229 return theRHS < theLHS;
1234 template <
class Type>
1240 return !(theLHS < theRHS);
1245 #if defined(_MSC_VER)
1246 #pragma warning(pop)
1251 XALAN_CPP_NAMESPACE_END
1255 #endif // XALANVECTOR_HEADER_GUARD_1357924680