19#if !defined(XALANVECTOR_HEADER_GUARD_1357924680)
20#define XALANVECTOR_HEADER_GUARD_1357924680
48#pragma warning(disable: 4100)
53using xercesc::MemoryManager;
57template <
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));
126 theTemp.insert(theTemp.begin(), theSource.begin(), theSource.end());
131 else if (theInitialAllocation > 0)
133 m_data = allocate(theInitialAllocation);
135 m_allocation = theInitialAllocation;
144 MemoryManager& theManager) :
145 m_memoryManager(&theManager),
153 theTemp.
insert(theTemp.
begin(), theFirst, 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)
225 destroy(m_data[m_size]);
237 if (theFirst != theLast)
244 shrinkCount(local_distance(theFirst, theLast));
255 return erase(position, position + 1);
266 assert(theFirst <= theLast);
267 assert(thePosition >=
begin());
268 assert(thePosition <=
end());
273 local_distance(theFirst, theLast);
275 if (theInsertSize == 0)
282 if (thePosition ==
end())
284 pointer thePointer = ensureCapacity(theTotalSize);
286 while (theFirst != theLast)
299 assert (m_memoryManager != 0);
301 ThisType theTemp(*m_memoryManager, theTotalSize);
307 theTemp.
insert(theTemp.
end(), theFirst, theLast);
320 local_distance(thePosition, theOriginalEnd);
322 if (theRightSplitSize <= theInsertSize)
328 const const_iterator toInsertSplit = theFirst + theRightSplitSize;
331 while (toInsertIter != theLast)
333 doPushBack(*toInsertIter);
339 toInsertIter = thePosition;
340 while (toInsertIter != theOriginalEnd)
342 doPushBack(*toInsertIter);
349 std::copy(theFirst, toInsertSplit, thePosition);
358 while (toMoveIter != theOriginalEnd)
360 doPushBack(*toMoveIter);
366 std::copy_backward(thePosition, theOriginalEnd - theInsertSize, theOriginalEnd);
369 std::copy(theFirst, theLast, thePosition);
388 if (thePosition ==
end())
390 pointer thePointer = ensureCapacity(theTotalSize);
392 for (
size_type index = 0; index < theCount; ++index)
404 assert ( m_memoryManager != 0 );
406 ThisType theTemp(*m_memoryManager, theTotalSize);
412 theTemp.
insert(theTemp.
end(), theCount, theData);
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);
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;
530 insert(theCount, theData);
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;
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);
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);
900 allocate(size_type size)
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)
1013 ensureCapacity(size_type theSize)
1015 if (theSize > capacity())
1020 return endPointer();
1024 doReserve(size_type theSize)
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(
"");
1056 shrinkToSize(size_type theSize)
1058 assert(m_size > theSize);
1063 }
while (m_size > theSize);
1067 shrinkCount(size_type theCount)
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;
1105template <
class Type>
1111 theLHS.
swap(theRHS);
1116template <
class Type>
1122 if (theLHS.
size() != theRHS.
size())
1126 else if (theLHS.
size() == 0)
1132 return std::equal(theLHS.
begin(), theLHS.
end(), theRHS.
begin());
1138template <
class Type>
1144 return !(theLHS == theRHS);
1149template <
class Type>
1155 return std::lexicographical_compare(
1164template <
class Type>
1170 return !(theRHS < theLHS);
1175template <
class Type>
1181 return theRHS < theLHS;
1186template <
class Type>
1192 return !(theLHS < theRHS);
1197#if defined(_MSC_VER)
#define XALAN_DEFAULT_CONSTRUCTOR_MEMMGR
MemoryManager & getMemoryManager()
reference at(size_type theIndex)
XalanVector(MemoryManager &theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR, size_type initialAllocation=size_type(0))
const value_type & const_reference
void swap(ThisType &theOther)
const XalanNode * value_type
void insert(iterator thePosition, const_iterator theFirst, const_iterator theLast)
iterator erase(iterator position)
void push_back(const value_type &data)
const_reference at(size_type theIndex) const
static XalanVector * create(const_iterator theFirst, const_iterator theLast, MemoryManager &theManager)
const_reference front() const
XalanVector(size_type theInsertSize, const value_type &theData, MemoryManager &theManager)
void assign(iterator theFirst, iterator theLast)
const value_type * const_pointer
XalanVector(const ThisType &theSource, MemoryManager &theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR, size_type theInitialAllocation=size_type(0))
MemoryManagedConstructionTraits< const XalanNode * >::Constructor Constructor
size_type max_size() const
iterator insert(iterator thePosition, const value_type &theData)
const_iterator end() const
const value_type * const_iterator
const_reference back() const
const_reverse_iterator_ const_reverse_iterator
static XalanVector * create(MemoryManager &theManager, size_type initialAllocation=size_type(0))
XalanVector(const_iterator theFirst, const_iterator theLast, MemoryManager &theManager)
const_reference operator[](size_type theIndex) const
const_reverse_iterator rbegin() const
const_iterator begin() const
XalanVector< value_type, MemoryManagedConstructionTraits< const XalanNode * > > ThisType
const_reverse_iterator rend() const
std::reverse_iterator< iterator > reverse_iterator_
void resize(size_type theSize, const value_type &theValue)
void assign(size_type theCount, const value_type &theData)
iterator erase(iterator theFirst, iterator theLast)
ThisType & operator=(const ThisType &theRHS)
ptrdiff_t difference_type
Constructor::ConstructableType ConstructibleType
reverse_iterator_ reverse_iterator
const MemoryManager & getMemoryManager() const
reverse_iterator rbegin()
std::reverse_iterator< const_iterator > const_reverse_iterator_
size_type capacity() const
reference operator[](size_type theIndex)
void assign(const_iterator theFirst, const_iterator theLast)
void reserve(size_type theSize)
void insert(iterator thePosition, size_type theCount, const value_type &theData)
void resize(size_type theSize)
void swap(XalanVector< Type > &theLHS, XalanVector< Type > &theRHS)
bool operator<(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
bool operator<=(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
bool operator!=(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
bool operator>(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
bool operator>=(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
static C * construct(C *address, MemoryManager &)
ConstructValueWithNoMemoryManager< C > ConstructableType