22 #if !defined(XALANVECTOR_HEADER_GUARD_1357924680)
23 #define XALANVECTOR_HEADER_GUARD_1357924680
46 XALAN_CPP_NAMESPACE_BEGIN
51 #pragma warning(disable: 4100)
56 XALAN_USING_XERCES(MemoryManager)
74 #if defined(XALAN_VCPP_USE_PTRIT)
95 #if defined(XALAN_HAS_STD_ITERATORS)
98 #elif defined(XALAN_RW_NO_CLASS_PARTIAL_SPEC)
101 XALAN_STD_QUALIFIER random_access_iterator_tag,
102 value_type> reverse_iterator_;
105 XALAN_STD_QUALIFIER random_access_iterator_tag,
106 const value_type> const_reverse_iterator_;
122 size_type initialAllocation =
size_type(0)) :
123 m_memoryManager(&theManager),
125 m_allocation(initialAllocation),
126 m_data(initialAllocation > 0 ? allocate(initialAllocation) : 0)
133 MemoryManager& theManager,
134 size_type initialAllocation =
size_type(0))
136 typedef XalanVector ThisType;
140 ThisType* theResult = theGuard.
get();
142 new (theResult) ThisType(theManager, initialAllocation);
150 const ThisType& theSource,
151 MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMORY_MGR,
152 size_type theInitialAllocation =
size_type(0)) :
153 m_memoryManager(&theManager),
158 if (theSource.m_size > 0)
160 ThisType theTemp(theManager, local_max(theSource.m_size, theInitialAllocation));
167 else if (theInitialAllocation > 0)
169 m_data = allocate(theInitialAllocation);
171 m_allocation = theInitialAllocation;
178 const_iterator theFirst,
179 const_iterator theLast,
180 MemoryManager& theManager) :
181 m_memoryManager(&theManager),
187 ThisType theTemp(theManager);
189 theTemp.
insert(theTemp.
begin(), theFirst, theLast);
198 const_iterator theFirst,
199 const_iterator theLast,
200 MemoryManager& theManager)
202 typedef XalanVector ThisType;
206 ThisType* theResult = theGuard.
get();
208 new (theResult) ThisType(theFirst, theLast, theManager);
216 size_type theInsertSize,
217 const value_type& theData,
218 MemoryManager& theManager) :
219 m_memoryManager(&theManager),
224 ThisType theTemp(theManager);
226 theTemp.
insert(theTemp.
begin(), theInsertSize, theData);
237 if (m_allocation != 0)
239 destroy(begin(), end());
262 destroy(m_data[m_size]);
274 if (theFirst != theLast)
276 XALAN_STD_QUALIFIER copy(
281 shrinkCount(local_distance(theFirst, theLast));
292 return erase(position, position + 1);
297 iterator thePosition,
298 const_iterator theFirst,
299 const_iterator theLast)
303 assert(theFirst <= theLast);
304 assert(thePosition >= begin());
305 assert(thePosition <= end());
309 const size_type theInsertSize =
310 local_distance(theFirst, theLast);
312 if (theInsertSize == 0)
317 const size_type theTotalSize = size() + theInsertSize;
319 if (thePosition == end())
321 pointer thePointer = ensureCapacity(theTotalSize);
323 while (theFirst != theLast)
325 Constructor::construct(thePointer, *theFirst, *m_memoryManager);
334 if (theTotalSize > capacity())
336 assert (m_memoryManager != 0);
338 ThisType theTemp(*m_memoryManager, theTotalSize);
341 theTemp.
insert(theTemp.
end(), begin(), thePosition);
344 theTemp.
insert(theTemp.
end(), theFirst, theLast);
347 theTemp.
insert(theTemp.
end(), thePosition, end());
354 const iterator theOriginalEnd = end();
356 const size_type theRightSplitSize =
357 local_distance(thePosition, theOriginalEnd);
359 if (theRightSplitSize <= theInsertSize)
365 const const_iterator toInsertSplit = theFirst + theRightSplitSize;
366 const_iterator toInsertIter = toInsertSplit;
368 while (toInsertIter != theLast)
370 doPushBack(*toInsertIter);
376 toInsertIter = thePosition;
377 while (toInsertIter != theOriginalEnd)
379 doPushBack(*toInsertIter);
386 XALAN_STD_QUALIFIER copy(theFirst, toInsertSplit, thePosition);
393 const_iterator toMoveIter = end() - theInsertSize;
395 while (toMoveIter != theOriginalEnd)
397 doPushBack(*toMoveIter);
403 XALAN_STD_QUALIFIER copy_backward(thePosition, theOriginalEnd - theInsertSize, theOriginalEnd);
406 XALAN_STD_QUALIFIER copy(theFirst, theLast, thePosition);
416 iterator thePosition,
418 const value_type& theData)
422 const size_type theTotalSize = size() + theCount;
425 if (thePosition == end())
427 pointer thePointer = ensureCapacity(theTotalSize);
429 for (size_type index = 0; index < theCount; ++index)
431 Constructor::construct(thePointer, theData, *m_memoryManager);
439 if (theTotalSize > capacity())
441 assert ( m_memoryManager != 0 );
443 ThisType theTemp(*m_memoryManager, theTotalSize);
446 theTemp.
insert(theTemp.
end(), begin(), thePosition);
449 theTemp.
insert(theTemp.
end(), theCount, theData);
452 theTemp.
insert(theTemp.
end(), thePosition, end());
459 const iterator theOriginalEnd = end();
461 const size_type theRightSplitSize =
462 local_distance(thePosition, theOriginalEnd);
464 if (theRightSplitSize <= theCount)
470 for (size_type i = 0; i < (theCount - theRightSplitSize); ++i)
476 iterator toInsertIter = thePosition;
478 while (toInsertIter != theOriginalEnd)
480 doPushBack(*toInsertIter);
487 XALAN_STD_QUALIFIER fill(thePosition, thePosition + theRightSplitSize, theData);
494 const_iterator toMoveIter = end() - theCount;
496 while (toMoveIter != theOriginalEnd)
498 doPushBack(*toMoveIter);
504 XALAN_STD_QUALIFIER copy_backward(thePosition, theOriginalEnd - theCount, theOriginalEnd);
507 XALAN_STD_QUALIFIER fill(thePosition, thePosition + theCount, theData);
517 iterator thePosition,
518 const value_type& theData)
520 if (m_allocation > m_size)
522 insert(thePosition, 1, theData);
528 const size_type theDistance =
529 local_distance(begin(), thePosition);
531 insert(thePosition, 1, theData);
533 return begin() + theDistance;
539 const_iterator theFirst,
540 const_iterator theLast)
556 const_iterator(theFirst),
557 const_iterator(theLast));
563 const value_type& theData)
567 insert(theCount, theData);
583 return ~size_type(0);
589 const ConstructibleType defaultValue(*m_memoryManager);
591 resize(theSize, defaultValue.value);
596 const value_type& theValue)
600 if (m_size > theSize)
602 shrinkToSize(theSize);
604 else if (m_size < theSize)
609 assert(m_allocation >= theSize);
611 const value_type*
const theEnd = m_data + theSize;
614 for (value_type* data = endPointer();
618 Constructor::construct(data, theValue, *m_memoryManager);
622 assert(m_size == theSize);
640 return m_size == 0 ?
true :
false;
648 if (theSize > m_allocation)
675 return m_data[m_size - 1];
681 return m_data[m_size - 1];
721 return reverse_iterator(end());
724 const_reverse_iterator
729 return const_reverse_iterator(end());
737 return reverse_iterator(begin());
740 const_reverse_iterator
745 return const_reverse_iterator(begin());
750 at(size_type theIndex)
752 if (theIndex >= m_size)
757 return m_data[theIndex];
761 at(size_type theIndex)
const
763 if (theIndex >= m_size)
768 return m_data[theIndex];
774 assert (theIndex < m_size);
776 return m_data[theIndex];
782 assert (theIndex < m_size);
784 return m_data[theIndex];
808 if (m_allocation < theRHS.m_size)
810 ThisType theTemp(theRHS,*m_memoryManager);
816 const_iterator theRHSCopyEnd = theRHS.
end();
818 if (m_size > theRHS.m_size)
821 shrinkToSize(theRHS.m_size);
823 else if (m_size < theRHS.m_size)
826 theRHS.
begin() + m_size;
835 XALAN_STD_QUALIFIER copy(
852 MemoryManager*
const theTempManager = m_memoryManager;
853 const size_type theTempLength = m_size;
854 const size_type theTempAllocation = m_allocation;
855 value_type*
const theTempData = m_data;
857 m_memoryManager = theOther.m_memoryManager;
858 m_size = theOther.m_size;
859 m_allocation = theOther.m_allocation;
860 m_data = theOther.m_data;
862 theOther.m_memoryManager = theTempManager;
863 theOther.m_size = theTempLength;
864 theOther.m_allocation = theTempAllocation;
865 theOther.m_data = theTempData;
873 return m_memoryManager;
879 assert (m_memoryManager != 0);
881 return *m_memoryManager;
894 value_type*
const theTemp = m_data;
912 assert(m_allocation >= m_size);
913 assert(m_data == 0 && m_allocation == 0 || m_data != 0 && m_allocation != 0);
919 const_iterator theFirst,
920 const_iterator theLast)
924 assert(theFirst <= theLast);
926 #if defined(XALAN_HAS_STD_DISTANCE)
927 return XALAN_STD_QUALIFIER distance(theFirst, theLast);
929 size_type theDistance;
931 XALAN_STD_QUALIFIER distance(theFirst, theLast, theDistance);
938 allocate(size_type size)
940 const size_type theBytesNeeded = size *
sizeof(value_type);
942 assert (m_memoryManager != 0);
944 void* pointer = m_memoryManager->allocate(theBytesNeeded);
946 assert(pointer != 0);
948 return (value_type*) pointer;
952 deallocate(value_type* pointer)
954 assert(m_memoryManager != 0);
956 m_memoryManager->deallocate(pointer);
961 destroy(value_type& theValue)
971 for(; theFirst != theLast; ++theFirst)
978 doPushBack(
const value_type& data)
982 if (m_size < m_allocation)
984 Constructor::construct(endPointer(), data, *m_memoryManager);
990 assert(m_size == m_allocation);
992 const size_type theNewSize = m_size == 0 ? 1 :
size_type((m_size * 1.6) + 0.5);
993 assert(theNewSize > m_size);
995 ThisType theTemp(*
this, *m_memoryManager, theNewSize);
997 theTemp.doPushBack(data);
1006 ensureCapacity(size_type theSize)
1008 if (theSize > capacity())
1013 return endPointer();
1017 doReserve(size_type theSize)
1021 assert(theSize > m_allocation);
1023 ThisType theTemp(*
this, *m_memoryManager, theSize);
1033 return m_data + m_size;
1039 return m_data + m_size;
1045 throw XALAN_STD_QUALIFIER out_of_range(
"");
1049 shrinkToSize(size_type theSize)
1051 assert(m_size > theSize);
1056 }
while (m_size > theSize);
1060 shrinkCount(size_type theCount)
1062 assert(m_size >= theCount);
1064 while (theCount > 0)
1077 return theLHS > theRHS ? theLHS : theRHS;
1080 #if defined(XALAN_DEVELOPMENT)
1082 XalanVector(
const XalanVector&);
1087 MemoryManager* m_memoryManager;
1091 size_type m_allocation;
1098 template <
class Type>
1104 theLHS.
swap(theRHS);
1109 template <
class Type>
1115 if (theLHS.
size() != theRHS.
size())
1119 else if (theLHS.
size() == 0)
1125 return XALAN_STD_QUALIFIER equal(theLHS.
begin(), theLHS.
end(), theRHS.
begin());
1131 template <
class Type>
1137 return !(theLHS == theRHS);
1142 template <
class Type>
1148 return XALAN_STD_QUALIFIER lexicographical_compare(
1157 template <
class Type>
1163 return !(theRHS < theLHS);
1168 template <
class Type>
1174 return theRHS < theLHS;
1179 template <
class Type>
1185 return !(theLHS < theRHS);
1190 #if defined(_MSC_VER)
1191 #pragma warning(pop)
1196 XALAN_CPP_NAMESPACE_END
1200 #endif // XALANVECTOR_HEADER_GUARD_1357924680
pointer detach()
Definition: XalanVector.hpp:889
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1111
Type value_type
Definition: XalanVector.hpp:66
reference at(size_type theIndex)
Definition: XalanVector.hpp:750
void reserve(XalanDOMString &theString, XalanDOMString::size_type theCount)
Reserve some space in the string for more efficient concatenation...
Definition: DOMStringHelper.hpp:261
XalanDOMString & assign(XalanDOMString &theString, const XalanDOMString &theStringToAssign)
Assign one string to another.
Definition: DOMStringHelper.hpp:2080
const value_type * const_iterator
Definition: XalanVector.hpp:92
void assign(const_iterator theFirst, const_iterator theLast)
Definition: XalanVector.hpp:538
void erase(XalanDOMString &theString)
Remove all elements from target string.
Definition: DOMStringHelper.hpp:2304
iterator end()
Definition: XalanVector.hpp:701
XALAN_STD_QUALIFIER reverse_iterator< iterator, value_type > reverse_iterator_
Definition: XalanVector.hpp:108
const_reference operator[](size_type theIndex) const
Definition: XalanVector.hpp:780
reference front()
Definition: XalanVector.hpp:657
XALAN_STD_QUALIFIER reverse_iterator< const_iterator, value_type, const_reference > const_reverse_iterator_
Definition: XalanVector.hpp:109
reverse_iterator rbegin()
Definition: XalanVector.hpp:717
MemoryManager & getMemoryManager()
Definition: XalanVector.hpp:877
value_type * iterator
Definition: XalanVector.hpp:91
void resize(size_type theSize, const value_type &theValue)
Definition: XalanVector.hpp:595
size_type capacity() const
Definition: XalanVector.hpp:628
const_reverse_iterator rbegin() const
Definition: XalanVector.hpp:725
XalanVector< value_type, ConstructionTraits > ThisType
Definition: XalanVector.hpp:115
ThisType & operator=(const ThisType &theRHS)
Definition: XalanVector.hpp:802
reference back()
Definition: XalanVector.hpp:673
void clear(XalanDOMString &theString)
Remove all elements from target string.
Definition: DOMStringHelper.hpp:2291
void pop_back()
Definition: XalanVector.hpp:256
bool operator<=(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1159
void resize(size_type theSize)
Definition: XalanVector.hpp:587
ConstructionTraits::Constructor Constructor
Definition: XalanVector.hpp:117
bool empty() const
Definition: XalanVector.hpp:636
void insert(iterator thePosition, size_type theCount, const value_type &theData)
Definition: XalanVector.hpp:415
void push_back(const value_type &data)
Definition: XalanVector.hpp:246
const_reference front() const
Definition: XalanVector.hpp:665
const value_type & const_reference
Definition: XalanVector.hpp:70
XalanVector(size_type theInsertSize, const value_type &theData, MemoryManager &theManager)
Definition: XalanVector.hpp:215
iterator begin()
Definition: XalanVector.hpp:685
bool operator!=(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1133
XalanVector(MemoryManager &theManager XALAN_DEFAULT_CONSTRUCTOR_MEMORY_MGR, size_type initialAllocation=size_type(0))
Definition: XalanVector.hpp:120
#define XALAN_DEFAULT_CONSTRUCTOR_MEMORY_MGR
Definition: XalanMemoryManagement.hpp:400
iterator erase(iterator position)
Definition: XalanVector.hpp:290
const_reference at(size_type theIndex) const
Definition: XalanVector.hpp:761
void assign(iterator theFirst, iterator theLast)
Definition: XalanVector.hpp:551
XalanVector(const_iterator theFirst, const_iterator theLast, MemoryManager &theManager)
Definition: XalanVector.hpp:177
ptrdiff_t difference_type
Definition: XalanVector.hpp:72
void insert(iterator thePosition, const_iterator theFirst, const_iterator theLast)
Definition: XalanVector.hpp:296
size_type max_size() const
Definition: XalanVector.hpp:579
iterator insert(iterator thePosition, const value_type &theData)
Definition: XalanVector.hpp:516
reverse_iterator rend()
Definition: XalanVector.hpp:733
bool operator>=(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1181
void reserve(size_type theSize)
Definition: XalanVector.hpp:644
void swap(XalanVector< Type > &theLHS, XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1100
const_reference back() const
Definition: XalanVector.hpp:679
XALAN_CPP_NAMESPACE_BEGIN typedef size_t size_type
Definition: XalanMap.hpp:44
bool operator<(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1144
const_reverse_iterator_ const_reverse_iterator
Definition: XalanVector.hpp:113
XalanVector(const ThisType &theSource, MemoryManager &theManager XALAN_DEFAULT_CONSTRUCTOR_MEMORY_MGR, size_type theInitialAllocation=size_type(0))
Definition: XalanVector.hpp:149
iterator erase(iterator theFirst, iterator theLast)
Definition: XalanVector.hpp:268
Type * get() const
Definition: XalanMemMgrAutoPtr.hpp:164
reverse_iterator_ reverse_iterator
Definition: XalanVector.hpp:112
void assign(size_type theCount, const value_type &theData)
Definition: XalanVector.hpp:561
~XalanVector()
Definition: XalanVector.hpp:233
size_t size_type
Definition: XalanVector.hpp:71
size_type size() const
Definition: XalanVector.hpp:571
bool operator>(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1170
Definition: XalanMemMgrAutoPtr.hpp:46
const value_type * const_pointer
Definition: XalanVector.hpp:68
static XalanVector * create(const_iterator theFirst, const_iterator theLast, MemoryManager &theManager)
Definition: XalanVector.hpp:197
void swap(ThisType &theOther)
Definition: XalanVector.hpp:848
const_iterator begin() const
Definition: XalanVector.hpp:693
static XalanVector * create(MemoryManager &theManager, size_type initialAllocation=size_type(0))
Definition: XalanVector.hpp:132
Constructor::ConstructableType ConstructibleType
Definition: XalanVector.hpp:118
Definition: XalanMemoryManagement.hpp:462
void clear()
Definition: XalanVector.hpp:788
Definition: XalanVector.hpp:61
value_type & reference
Definition: XalanVector.hpp:69
XalanDOMString & insert(XalanDOMString &theString, XalanDOMString::size_type thePosition, const XalanDOMString &theStringToInsert)
Insert a string into another string.
Definition: DOMStringHelper.hpp:2241
const MemoryManager * getMemoryManager() const
Definition: XalanVector.hpp:871
const_reverse_iterator rend() const
Definition: XalanVector.hpp:741
const_iterator end() const
Definition: XalanVector.hpp:709
reference operator[](size_type theIndex)
Definition: XalanVector.hpp:772
value_type * pointer
Definition: XalanVector.hpp:67