Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


XalanVector.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #if !defined(XALANVECTOR_HEADER_GUARD_1357924680)
20 #define XALANVECTOR_HEADER_GUARD_1357924680
21 
22 
23 
24 // Base include file. Must be first.
26 
27 
28 
29 #include <cstddef>
30 #include <algorithm>
31 #include <cassert>
32 #include <new>
33 #include <iterator>
34 #include <stdexcept>
35 
36 
37 
39 
40 
41 
42 XALAN_CPP_NAMESPACE_BEGIN
43 
44 
45 
46 #if defined(_MSC_VER)
47 #pragma warning(push)
48 #pragma warning(disable: 4100)
49 #endif
50 
51 
52 
53 XALAN_USING_XERCES(MemoryManager)
54 
55 
56 
57 template <class Type, class ConstructionTraits = MemoryManagedConstructionTraits<Type> >
59 {
60 public:
61 
62 
63  typedef Type value_type;
64  typedef value_type* pointer;
65  typedef const value_type* const_pointer;
66  typedef value_type& reference;
67  typedef const value_type& const_reference;
68  typedef size_t size_type;
69  typedef ptrdiff_t difference_type;
70 
71 #if defined(XALAN_VCPP_USE_PTRIT)
72  typedef std::_Ptrit<
73  Type,
74  ptrdiff_t,
75  pointer,
76  reference,
77  pointer,
78  reference> iterator;
79 
80  typedef std::_Ptrit<
81  Type,
82  ptrdiff_t,
85  pointer,
86  reference> const_iterator;
87 #else
88  typedef value_type* iterator;
89  typedef const value_type* const_iterator;
90 #endif
91 
92 #if defined(XALAN_HAS_STD_ITERATORS)
93  typedef XALAN_STD_QUALIFIER reverse_iterator<iterator> reverse_iterator_;
95 #elif defined(XALAN_RW_NO_CLASS_PARTIAL_SPEC)
96  typedef XALAN_STD_QUALIFIER random_access_iterator_tag iterator_category;
97 
98  // This is a specific case for the Rogue Wave STL on Solaris.
99  typedef XALAN_STD_QUALIFIER reverse_iterator<
100  iterator,
101  iterator_category,
102  value_type> reverse_iterator_;
103  typedef XALAN_STD_QUALIFIER reverse_iterator<
105  iterator_category,
106  const value_type> const_reverse_iterator_;
107 #else
108  typedef XALAN_STD_QUALIFIER reverse_iterator<
109  iterator,
110  value_type> reverse_iterator_;
111  typedef XALAN_STD_QUALIFIER reverse_iterator<
113  value_type,
114  const_reference> const_reverse_iterator_;
115 #endif
116 
117  typedef reverse_iterator_ reverse_iterator;
118  typedef const_reverse_iterator_ const_reverse_iterator;
119 
121 
122  typedef typename ConstructionTraits::Constructor Constructor;
123  typedef typename Constructor::ConstructableType ConstructibleType;
124 
126  MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR,
127  size_type initialAllocation = size_type(0)) :
128  m_memoryManager(&theManager),
129  m_size(0),
130  m_allocation(initialAllocation),
131  m_data(initialAllocation > 0 ? allocate(initialAllocation) : 0)
132  {
133  invariants();
134  }
135 
136  static XalanVector*
138  MemoryManager& theManager,
139  size_type initialAllocation = size_type(0))
140  {
141  typedef XalanVector ThisType;
142 
143  XalanAllocationGuard theGuard(theManager, theManager.allocate(sizeof(ThisType)));
144 
145  ThisType* const theResult =
146  new (theGuard.get()) ThisType(theManager, initialAllocation);
147 
148  theGuard.release();
149 
150  return theResult;
151  }
152 
154  const ThisType& theSource,
155  MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR,
156  size_type theInitialAllocation = size_type(0)) :
157  m_memoryManager(&theManager),
158  m_size(0),
159  m_allocation(0),
160  m_data(0)
161  {
162  if (theSource.m_size > 0)
163  {
164  ThisType theTemp(theManager, local_max(theSource.m_size, theInitialAllocation));
165 
166  theTemp.insert(theTemp.begin(), theSource.begin(), theSource.end());
167 
168  swap(theTemp);
169 
170  }
171  else if (theInitialAllocation > 0)
172  {
173  m_data = allocate(theInitialAllocation);
174 
175  m_allocation = theInitialAllocation;
176  }
177 
178  invariants();
179  }
180 
182  const_iterator theFirst,
183  const_iterator theLast,
184  MemoryManager& theManager) :
185  m_memoryManager(&theManager),
186  m_size(0),
187  m_allocation(0),
188  m_data(0)
189 
190  {
191  ThisType theTemp(theManager);
192 
193  theTemp.insert(theTemp.begin(), theFirst, theLast);
194 
195  swap(theTemp);
196 
197  invariants();
198  }
199 
200  static XalanVector*
202  const_iterator theFirst,
203  const_iterator theLast,
204  MemoryManager& theManager)
205  {
206  typedef XalanVector ThisType;
207 
208  XalanAllocationGuard theGuard(theManager, theManager.allocate(sizeof(ThisType)));
209 
210  ThisType* const theResult =
211  new (theGuard.get()) ThisType(theFirst, theLast, theManager);
212 
213  theGuard.release();
214 
215  return theResult;
216  }
217 
219  size_type theInsertSize,
220  const value_type& theData,
221  MemoryManager& theManager) :
222  m_memoryManager(&theManager),
223  m_size(0),
224  m_allocation(0),
225  m_data(0)
226  {
227  ThisType theTemp(theManager);
228 
229  theTemp.insert(theTemp.begin(), theInsertSize, theData);
230 
231  swap(theTemp);
232 
233  invariants();
234  }
235 
237  {
238  invariants();
239 
240  if (m_allocation != 0)
241  {
242  destroy(begin(), end());
243 
244  deallocate(m_data);
245  }
246  }
247 
248  void
249  push_back(const value_type& data)
250  {
251  invariants();
252 
253  doPushBack(data);
254 
255  invariants();
256  }
257 
258  void
260  {
261  invariants();
262 
263  --m_size;
264 
265  destroy(m_data[m_size]);
266 
267  invariants();
268  }
269 
270  iterator
272  iterator theFirst,
273  iterator theLast)
274  {
275  invariants();
276 
277  if (theFirst != theLast)
278  {
279  XALAN_STD_QUALIFIER copy(
280  theLast,
281  end(),
282  theFirst);
283 
284  shrinkCount(local_distance(theFirst, theLast));
285  }
286 
287  invariants();
288 
289  return theFirst;
290  }
291 
292  iterator
293  erase(iterator position)
294  {
295  return erase(position, position + 1);
296  }
297 
298  void
300  iterator thePosition,
301  const_iterator theFirst,
302  const_iterator theLast)
303  {
304  // Since we're using bare pointers for now, we can
305  // assert this...
306  assert(theFirst <= theLast);
307  assert(thePosition >= begin());
308  assert(thePosition <= end());
309 
310  invariants();
311 
312  const size_type theInsertSize =
313  local_distance(theFirst, theLast);
314 
315  if (theInsertSize == 0)
316  {
317  return;
318  }
319 
320  const size_type theTotalSize = size() + theInsertSize;
321 
322  if (thePosition == end())
323  {
324  pointer thePointer = ensureCapacity(theTotalSize);
325 
326  while (theFirst != theLast)
327  {
328  Constructor::construct(thePointer, *theFirst, *m_memoryManager);
329 
330  ++thePointer;
331  ++m_size;
332  ++theFirst;
333  }
334  }
335  else
336  {
337  if (theTotalSize > capacity())
338  {
339  assert (m_memoryManager != 0);
340 
341  ThisType theTemp(*m_memoryManager, theTotalSize);
342 
343  // insert everything up to the position...
344  theTemp.insert(theTemp.end(), begin(), thePosition);
345 
346  // insert the new stuff...
347  theTemp.insert(theTemp.end(), theFirst, theLast);
348 
349  // insert everything from the position to the end...
350  theTemp.insert(theTemp.end(), thePosition, end());
351 
352  swap(theTemp);
353  }
354  else
355  {
356  // insert into the middle of the vector that has enough capacity
357  const iterator theOriginalEnd = end();
358 
359  const size_type theRightSplitSize =
360  local_distance(thePosition, theOriginalEnd);
361 
362  if (theRightSplitSize <= theInsertSize)
363  {
364  // inserted range will go to or beyond edge of current vector
365 
366  // append from inserted range, all values that will extend
367  // beyond the current vector
368  const const_iterator toInsertSplit = theFirst + theRightSplitSize;
369  const_iterator toInsertIter = toInsertSplit;
370 
371  while (toInsertIter != theLast)
372  {
373  doPushBack(*toInsertIter);
374 
375  ++toInsertIter;
376  }
377 
378  // copy the "right" of the current vector to the end
379  toInsertIter = thePosition;
380  while (toInsertIter != theOriginalEnd)
381  {
382  doPushBack(*toInsertIter);
383 
384  ++toInsertIter;
385  }
386 
387  // copy the remaining part of inserted range into
388  // the original vector spaces
389  XALAN_STD_QUALIFIER copy(theFirst, toInsertSplit, thePosition);
390  }
391  else
392  {
393  // inserted range will not extend beyond edge of current vector
394 
395  // move end of current vector by insertion size
396  const_iterator toMoveIter = end() - theInsertSize;
397 
398  while (toMoveIter != theOriginalEnd)
399  {
400  doPushBack(*toMoveIter);
401 
402  ++toMoveIter;
403  }
404 
405  // reverse copy the remaining part of the "right" piece of the current vector
406  XALAN_STD_QUALIFIER copy_backward(thePosition, theOriginalEnd - theInsertSize, theOriginalEnd);
407 
408  // insert into current vector
409  XALAN_STD_QUALIFIER copy(theFirst, theLast, thePosition);
410  }
411  }
412  }
413 
414  invariants();
415  }
416 
417  void
419  iterator thePosition,
420  size_type theCount,
421  const value_type& theData)
422  {
423  invariants();
424 
425  const size_type theTotalSize = size() + theCount;
426 
427  // Needs to be optimized
428  if (thePosition == end())
429  {
430  pointer thePointer = ensureCapacity(theTotalSize);
431 
432  for (size_type index = 0; index < theCount; ++index)
433  {
434  Constructor::construct(thePointer, theData, *m_memoryManager);
435 
436  ++thePointer;
437  ++m_size;
438  }
439  }
440  else
441  {
442  if (theTotalSize > capacity())
443  {
444  assert ( m_memoryManager != 0 );
445 
446  ThisType theTemp(*m_memoryManager, theTotalSize);
447 
448  // insert everything up to the position...
449  theTemp.insert(theTemp.end(), begin(), thePosition);
450 
451  // insert the new stuff...
452  theTemp.insert(theTemp.end(), theCount, theData);
453 
454  // insert everything from the position to the end...
455  theTemp.insert(theTemp.end(), thePosition, end());
456 
457  swap(theTemp);
458  }
459  else
460  {
461  // insert into the middle of the vector that has enough capacity
462  const iterator theOriginalEnd = end();
463 
464  const size_type theRightSplitSize =
465  local_distance(thePosition, theOriginalEnd);
466 
467  if (theRightSplitSize <= theCount)
468  {
469  // inserted range will go to or beyond edge of current vector
470 
471  // append all copies that will extend
472  // beyond the current vector
473  for (size_type i = 0; i < (theCount - theRightSplitSize); ++i)
474  {
475  doPushBack(theData);
476  }
477 
478  // copy the "right" of the current vector to the end
479  iterator toInsertIter = thePosition;
480 
481  while (toInsertIter != theOriginalEnd)
482  {
483  doPushBack(*toInsertIter);
484 
485  ++toInsertIter;
486  }
487 
488  // copy the remaining part of inserted range into
489  // the original vector spaces
490  XALAN_STD_QUALIFIER fill(thePosition, thePosition + theRightSplitSize, theData);
491  }
492  else
493  {
494  // inserted range will not extend beyond edge of current vector
495 
496  // move end of current vector by insertion size
497  const_iterator toMoveIter = end() - theCount;
498 
499  while (toMoveIter != theOriginalEnd)
500  {
501  doPushBack(*toMoveIter);
502 
503  ++toMoveIter;
504  }
505 
506  // reverse copy the remaining part of the "right" piece of the current vector
507  XALAN_STD_QUALIFIER copy_backward(thePosition, theOriginalEnd - theCount, theOriginalEnd);
508 
509  // insert into current vector
510  XALAN_STD_QUALIFIER fill(thePosition, thePosition + theCount, theData);
511  }
512  }
513  }
514 
515  invariants();
516  }
517 
518  iterator
520  iterator thePosition,
521  const value_type& theData)
522  {
523  if (m_allocation > m_size)
524  {
525  insert(thePosition, 1, theData);
526 
527  return thePosition;
528  }
529  else
530  {
531  const size_type theDistance =
532  local_distance(begin(), thePosition);
533 
534  insert(thePosition, 1, theData);
535 
536  return begin() + theDistance;
537  }
538  }
539 
540  void
542  const_iterator theFirst,
543  const_iterator theLast)
544  {
545  clear();
546 
547  insert(
548  begin(),
549  theFirst,
550  theLast);
551  }
552 
553  void
555  iterator theFirst,
556  iterator theLast)
557  {
558  assign(
559  const_iterator(theFirst),
560  const_iterator(theLast));
561  }
562 
563  void
565  size_type theCount,
566  const value_type& theData)
567  {
568  clear();
569 
570  insert(theCount, theData);
571  }
572 
573  size_type
574  size() const
575  {
576  invariants();
577 
578  return m_size;
579  }
580 
581  size_type
582  max_size() const
583  {
584  invariants();
585 
586  return ~size_type(0);
587  }
588 
589  void
590  resize(size_type theSize)
591  {
592  const ConstructibleType defaultValue(*m_memoryManager);
593 
594  resize(theSize, defaultValue.value);
595  }
596 
597  void
599  size_type theSize,
600  const value_type& theValue)
601  {
602  invariants();
603 
604  if (m_size > theSize)
605  {
606  shrinkToSize(theSize);
607  }
608  else if (m_size < theSize)
609  {
610  // Reserve memory up-front...
611  reserve(theSize);
612 
613  assert(m_allocation >= theSize);
614 
615  const value_type* const theEnd = m_data + theSize;
616 
617  // Fill the new area...
618  for (value_type* data = endPointer();
619  data != theEnd;
620  ++data, ++m_size)
621  {
622  Constructor::construct(data, theValue, *m_memoryManager);
623  }
624  }
625 
626  assert(m_size == theSize);
627 
628  invariants();
629  }
630 
631  size_type
632  capacity() const
633  {
634  invariants();
635 
636  return m_allocation;
637  }
638 
639  bool
640  empty() const
641  {
642  invariants();
643 
644  return m_size == 0 ? true : false;
645  }
646 
647  void
648  reserve(size_type theSize)
649  {
650  invariants();
651 
652  if (theSize > m_allocation)
653  {
654  doReserve(theSize);
655  }
656 
657  invariants();
658  }
659 
660  reference
662  {
663  invariants();
664 
665  return m_data[0];
666  }
667 
668  const_reference
669  front() const
670  {
671  invariants();
672 
673  return m_data[0];
674  }
675 
676  reference
678  {
679  return m_data[m_size - 1];
680  }
681 
682  const_reference
683  back() const
684  {
685  return m_data[m_size - 1];
686  }
687 
688  iterator
690  {
691  invariants();
692 
693  return m_data;
694  }
695 
696  const_iterator
697  begin() const
698  {
699  invariants();
700 
701  return m_data;
702  }
703 
704  iterator
705  end()
706  {
707  invariants();
708 
709  return endPointer();
710  }
711 
712  const_iterator
713  end() const
714  {
715  invariants();
716 
717  return endPointer();
718  }
719 
720  reverse_iterator
722  {
723  invariants();
724 
725  return reverse_iterator(end());
726  }
727 
728  const_reverse_iterator
729  rbegin() const
730  {
731  invariants();
732 
733  return const_reverse_iterator(end());
734  }
735 
736  reverse_iterator
738  {
739  invariants();
740 
741  return reverse_iterator(begin());
742  }
743 
744  const_reverse_iterator
745  rend() const
746  {
747  invariants();
748 
749  return const_reverse_iterator(begin());
750  }
751 
752 
753  reference
754  at(size_type theIndex)
755  {
756  if (theIndex >= m_size)
757  {
758  outOfRange();
759  }
760 
761  return m_data[theIndex];
762  }
763 
764  const_reference
765  at(size_type theIndex) const
766  {
767  if (theIndex >= m_size)
768  {
769  outOfRange();
770  }
771 
772  return m_data[theIndex];
773  }
774 
775  reference
776  operator[](size_type theIndex)
777  {
778  assert (theIndex < m_size);
779 
780  return m_data[theIndex];
781  }
782 
783  const_reference
784  operator[](size_type theIndex) const
785  {
786  assert (theIndex < m_size);
787 
788  return m_data[theIndex];
789  }
790 
791  void
793  {
794  invariants();
795 
796  if (m_size > 0)
797  {
798  shrinkToSize(0);
799  }
800 
801  invariants();
802  }
803 
804  // Operators...
805  ThisType&
806  operator=(const ThisType& theRHS)
807  {
808  invariants();
809 
810  if (&theRHS != this)
811  {
812  if (m_allocation < theRHS.m_size)
813  {
814  ThisType theTemp(theRHS,*m_memoryManager);
815 
816  swap(theTemp);
817  }
818  else
819  {
820  const_iterator theRHSCopyEnd = theRHS.end();
821 
822  if (m_size > theRHS.m_size)
823  {
824  // Resize to the target size...
825  shrinkToSize(theRHS.m_size);
826  }
827  else if (m_size < theRHS.m_size)
828  {
829  // Insert the portion of theRHS that won't fit
830  // at the end...
831  theRHSCopyEnd =
832  theRHS.begin() + m_size;
833 
834  insert(
835  end(),
836  theRHSCopyEnd,
837  theRHS.end());
838  }
839 
840  // Copy everything that already exists...
841  XALAN_STD_QUALIFIER copy(
842  theRHS.begin(),
843  theRHSCopyEnd,
844  begin());
845  }
846  }
847 
848  invariants();
849 
850  return *this;
851  }
852 
853  void
854  swap(ThisType& theOther)
855  {
856  invariants();
857 
858  MemoryManager* const theTempManager = m_memoryManager;
859  const size_type theTempLength = m_size;
860  const size_type theTempAllocation = m_allocation;
861  value_type* const theTempData = m_data;
862 
863  m_memoryManager = theOther.m_memoryManager;
864  m_size = theOther.m_size;
865  m_allocation = theOther.m_allocation;
866  m_data = theOther.m_data;
867 
868  theOther.m_memoryManager = theTempManager;
869  theOther.m_size = theTempLength;
870  theOther.m_allocation = theTempAllocation;
871  theOther.m_data = theTempData;
872 
873  invariants();
874  }
875 
876  const MemoryManager&
878  {
879  assert (m_memoryManager != 0);
880 
881  return *m_memoryManager;
882  }
883 
884  MemoryManager&
886  {
887  assert (m_memoryManager != 0);
888 
889  return *m_memoryManager;
890  }
891 
892  // Detaches the allocated memory from the vector, and returns
893  // the pointer to the caller. The caller then owns the memory
894  // and must destroy any objects and deallocate it using the
895  // the memory manager returned from getMemoryManager()
896  pointer
898  {
899  m_size = 0;
900  m_allocation = 0;
901 
902  value_type* const theTemp = m_data;
903 
904  m_data = 0;
905 
906  return theTemp;
907  }
908 
909 private:
910 
911 #if defined(NDEBUG)
912  void
913  invariants() const
914  {
915  }
916 #else
917  void
918  invariants() const
919  {
920  assert(m_allocation >= m_size);
921  assert(
922  (m_data == 0 && m_allocation == 0) ||
923  (m_data != 0 && m_allocation != 0));
924  }
925 #endif
926 
927  size_type
928  local_distance(
929  const_iterator theFirst,
930  const_iterator theLast)
931  {
932  // Since we're using bare pointers for now, we can
933  // assert this...
934  assert(theFirst <= theLast);
935 
936 #if defined(XALAN_HAS_STD_DISTANCE)
937  return XALAN_STD_QUALIFIER distance(theFirst, theLast);
938 #else
939  size_type theDistance = size_type(0);
940 
941  XALAN_STD_QUALIFIER distance(theFirst, theLast, theDistance);
942 
943  return theDistance;
944 #endif
945  }
946 
947  value_type*
948  allocate(size_type size)
949  {
950  const size_type theBytesNeeded = size * sizeof(value_type);
951 
952  assert (m_memoryManager != 0);
953 
954  void* pointer = m_memoryManager->allocate(theBytesNeeded);
955 
956  assert(pointer != 0);
957 
958  return (value_type*) pointer;
959  }
960 
961  void
962  deallocate(value_type* pointer)
963  {
964  assert(m_memoryManager != 0);
965 
966  m_memoryManager->deallocate(pointer);
967 
968  }
969 
970  static void
971  destroy(value_type& theValue)
972  {
973  theValue.~Type();
974  }
975 
976  static void
977  destroy(
978  iterator theFirst,
979  iterator theLast)
980  {
981  for(; theFirst != theLast; ++theFirst)
982  {
983  destroy(*theFirst);
984  }
985  }
986 
987  void
988  grow(const value_type& data)
989  {
990  invariants();
991 
992  assert(m_size != 0 && m_size == m_allocation);
993 
994  const size_type theNewSize = size_type((m_size * 1.6) + 0.5);
995  assert(theNewSize > m_size);
996 
997  ThisType theTemp(*this, *m_memoryManager, theNewSize);
998 
999  theTemp.doPushBack(data);
1000 
1001  swap(theTemp);
1002 
1003  invariants();
1004  }
1005 
1006  void
1007  construct_back(const value_type& data)
1008  {
1009  invariants();
1010 
1011  assert(m_size < m_allocation);
1012 
1013  Constructor::construct(
1014  endPointer(),
1015  data,
1016  *m_memoryManager);
1017 
1018  ++m_size;
1019 
1020  invariants();
1021  }
1022 
1023  void
1024  init(const value_type& data)
1025  {
1026  invariants();
1027 
1028  assert(m_size == 0 && m_allocation == 0);
1029 
1030  m_data = allocate(1);
1031 
1032  m_allocation = 1;
1033 
1034  construct_back(data);
1035 
1036  invariants();
1037  }
1038 
1039  void
1040  doPushBack(const value_type& data)
1041  {
1042  invariants();
1043 
1044  if (m_size < m_allocation)
1045  {
1046  construct_back(data);
1047  }
1048  else if (m_size == 0)
1049  {
1050  init(data);
1051  }
1052  else
1053  {
1054  grow(data);
1055  }
1056 
1057  invariants();
1058  }
1059 
1060  pointer
1061  ensureCapacity(size_type theSize)
1062  {
1063  if (theSize > capacity())
1064  {
1065  doReserve(theSize);
1066  }
1067 
1068  return endPointer();
1069  }
1070 
1071  void
1072  doReserve(size_type theSize)
1073  {
1074  invariants();
1075 
1076  assert(theSize > m_allocation);
1077 
1078  ThisType theTemp(*this, *m_memoryManager, theSize);
1079 
1080  swap(theTemp);
1081 
1082  invariants();
1083  }
1084 
1085  pointer
1086  endPointer()
1087  {
1088  return m_data + m_size;
1089  }
1090 
1091  const_pointer
1092  endPointer() const
1093  {
1094  return m_data + m_size;
1095  }
1096 
1097  static void
1098  outOfRange()
1099  {
1100  throw XALAN_STD_QUALIFIER out_of_range("");
1101  }
1102 
1103  void
1104  shrinkToSize(size_type theSize)
1105  {
1106  assert(m_size > theSize);
1107 
1108  do
1109  {
1110  pop_back();
1111  } while (m_size > theSize);
1112  }
1113 
1114  void
1115  shrinkCount(size_type theCount)
1116  {
1117  assert(m_size >= theCount);
1118 
1119  while (theCount > 0)
1120  {
1121  pop_back();
1122 
1123  --theCount;
1124  }
1125  }
1126 
1127  size_type
1128  local_max(
1129  size_type theLHS,
1130  size_type theRHS)
1131  {
1132  return theLHS > theRHS ? theLHS : theRHS;
1133  }
1134 
1135 #if defined(XALAN_DEVELOPMENT)
1136  //not implemented
1137  XalanVector(const XalanVector&);
1138  XalanVector();
1139 #endif
1140 
1141  // Data members...
1142  MemoryManager* m_memoryManager;
1143 
1144  size_type m_size;
1145 
1146  size_type m_allocation;
1147 
1148  value_type* m_data;
1149 };
1150 
1151 
1152 
1153 template <class Type>
1154 inline void
1156  XalanVector<Type>& theLHS,
1157  XalanVector<Type>& theRHS)
1158 {
1159  theLHS.swap(theRHS);
1160 }
1161 
1162 
1163 
1164 template <class Type>
1165 inline bool
1167  const XalanVector<Type>& theLHS,
1168  const XalanVector<Type>& theRHS)
1169 {
1170  if (theLHS.size() != theRHS.size())
1171  {
1172  return false;
1173  }
1174  else if (theLHS.size() == 0)
1175  {
1176  return true;
1177  }
1178  else
1179  {
1180  return XALAN_STD_QUALIFIER equal(theLHS.begin(), theLHS.end(), theRHS.begin());
1181  }
1182 }
1183 
1184 
1185 
1186 template <class Type>
1187 inline bool
1189  const XalanVector<Type>& theLHS,
1190  const XalanVector<Type>& theRHS)
1191 {
1192  return !(theLHS == theRHS);
1193 }
1194 
1195 
1196 
1197 template <class Type>
1198 inline bool
1200  const XalanVector<Type>& theLHS,
1201  const XalanVector<Type>& theRHS)
1202 {
1203  return XALAN_STD_QUALIFIER lexicographical_compare(
1204  theLHS.begin(),
1205  theLHS.end(),
1206  theRHS.begin(),
1207  theRHS.end());
1208 }
1209 
1210 
1211 
1212 template <class Type>
1213 inline bool
1215  const XalanVector<Type>& theLHS,
1216  const XalanVector<Type>& theRHS)
1217 {
1218  return !(theRHS < theLHS);
1219 }
1220 
1221 
1222 
1223 template <class Type>
1224 inline bool
1226  const XalanVector<Type>& theLHS,
1227  const XalanVector<Type>& theRHS)
1228 {
1229  return theRHS < theLHS;
1230 }
1231 
1232 
1233 
1234 template <class Type>
1235 inline bool
1237  const XalanVector<Type>& theLHS,
1238  const XalanVector<Type>& theRHS)
1239 {
1240  return !(theLHS < theRHS);
1241 }
1242 
1243 
1244 
1245 #if defined(_MSC_VER)
1246 #pragma warning(pop)
1247 #endif
1248 
1249 
1250 
1251 XALAN_CPP_NAMESPACE_END
1252 
1253 
1254 
1255 #endif // XALANVECTOR_HEADER_GUARD_1357924680
pointer detach()
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
reference at(size_type theIndex)
const_iterator end() const
const value_type * const_iterator
Definition: XalanVector.hpp:89
void assign(const_iterator theFirst, const_iterator theLast)
iterator end()
reference front()
reverse_iterator rbegin()
size_type capacity() const
MemoryManager & getMemoryManager()
value_type * iterator
Definition: XalanVector.hpp:88
const_reverse_iterator rbegin() const
void resize(size_type theSize, const value_type &theValue)
#define XALAN_DEFAULT_CONSTRUCTOR_MEMMGR
XalanVector< value_type, ConstructionTraits > ThisType
ThisType & operator=(const ThisType &theRHS)
const_reference operator[](size_type theIndex) const
reference back()
void pop_back()
bool operator<=(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
void resize(size_type theSize)
ConstructionTraits::Constructor Constructor
void insert(iterator thePosition, size_type theCount, const value_type &theData)
void push_back(const value_type &data)
const value_type & const_reference
Definition: XalanVector.hpp:67
XalanVector(const ThisType &theSource, MemoryManager &theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR, size_type theInitialAllocation=size_type(0))
XalanVector(size_type theInsertSize, const value_type &theData, MemoryManager &theManager)
iterator begin()
bool operator!=(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
iterator erase(iterator position)
void assign(iterator theFirst, iterator theLast)
XalanVector(const_iterator theFirst, const_iterator theLast, MemoryManager &theManager)
ptrdiff_t difference_type
Definition: XalanVector.hpp:69
void insert(iterator thePosition, const_iterator theFirst, const_iterator theLast)
iterator insert(iterator thePosition, const value_type &theData)
XALAN_STD_QUALIFIER reverse_iterator< iterator, value_type > reverse_iterator_
reverse_iterator rend()
bool operator>=(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
void reserve(size_type theSize)
size_type size() const
bool operator<(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
const_reverse_iterator_ const_reverse_iterator
bool empty() const
iterator erase(iterator theFirst, iterator theLast)
reverse_iterator_ reverse_iterator
void assign(size_type theCount, const value_type &theData)
size_t size_type
Definition: XalanVector.hpp:68
bool operator>(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
const MemoryManager & getMemoryManager() const
const_iterator begin() const
const value_type * const_pointer
Definition: XalanVector.hpp:65
static XalanVector * create(const_iterator theFirst, const_iterator theLast, MemoryManager &theManager)
void swap(ThisType &theOther)
static XalanVector * create(MemoryManager &theManager, size_type initialAllocation=size_type(0))
Constructor::ConstructableType ConstructibleType
const_reference at(size_type theIndex) const
XalanVector(MemoryManager &theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR, size_type initialAllocation=size_type(0))
XALAN_CPP_NAMESPACE_BEGIN XALAN_USING_XERCES(Locator)
const_reference back() const
XALAN_STD_QUALIFIER reverse_iterator< const_iterator, value_type, const_reference > const_reverse_iterator_
const_reference front() const
const_reverse_iterator rend() const
value_type & reference
Definition: XalanVector.hpp:66
reference operator[](size_type theIndex)
value_type * pointer
Definition: XalanVector.hpp:64
size_type max_size() const

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSLT Processor Version 1.11
Copyright © 1999-2012 The Apache Software Foundation.
All Rights Reserved.

Apache Logo