Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OVR_Array.h
Go to the documentation of this file.
1 /************************************************************************************
2 
3 PublicHeader: OVR.h
4 Filename : OVR_Array.h
5 Content : Template implementation for Array
6 Created : September 19, 2012
7 Notes :
8 
9 Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 
11 Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 you may not use the Oculus VR Rift SDK except in compliance with the License,
13 which is provided at the time of installation or download, or which
14 otherwise accompanies this software in either electronic or hard copy form.
15 
16 You may obtain a copy of the License at
17 
18 http://www.oculusvr.com/licenses/LICENSE-3.1
19 
20 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 distributed under the License is distributed on an "AS IS" BASIS,
22 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 See the License for the specific language governing permissions and
24 limitations under the License.
25 
26 ************************************************************************************/
27 
28 #ifndef OVR_Array_h
29 #define OVR_Array_h
30 
31 #include "OVR_ContainerAllocator.h"
32 
33 namespace OVR {
34 
35 //-----------------------------------------------------------------------------------
36 // ***** ArrayDefaultPolicy
37 //
38 // Default resize behavior. No minimal capacity, Granularity=4,
39 // Shrinking as needed. ArrayConstPolicy actually is the same as
40 // ArrayDefaultPolicy, but parametrized with constants.
41 // This struct is used only in order to reduce the template "matroska".
43 {
46 
47  UPInt GetMinCapacity() const { return 0; }
48  UPInt GetGranularity() const { return 4; }
49  bool NeverShrinking() const { return 0; }
50 
51  UPInt GetCapacity() const { return Capacity; }
52  void SetCapacity(UPInt capacity) { Capacity = capacity; }
53 private:
55 };
56 
57 
58 //-----------------------------------------------------------------------------------
59 // ***** ArrayConstPolicy
60 //
61 // Statically parametrized resizing behavior:
62 // MinCapacity, Granularity, and Shrinking flag.
63 template<int MinCapacity=0, int Granularity=4, bool NeverShrink=false>
65 {
67 
70 
71  UPInt GetMinCapacity() const { return MinCapacity; }
72  UPInt GetGranularity() const { return Granularity; }
73  bool NeverShrinking() const { return NeverShrink; }
74 
75  UPInt GetCapacity() const { return Capacity; }
76  void SetCapacity(UPInt capacity) { Capacity = capacity; }
77 private:
79 };
80 
81 //-----------------------------------------------------------------------------------
82 // ***** ArrayDataBase
83 //
84 // Basic operations with array data: Reserve, Resize, Free, ArrayPolicy.
85 // For internal use only: ArrayData,ArrayDataCC and others.
86 template<class T, class Allocator, class SizePolicy>
88 {
89  typedef T ValueType;
91  typedef SizePolicy SizePolicyType;
93 
95  : Data(0), Size(0), Policy() {}
96 
97  ArrayDataBase(const SizePolicy& p)
98  : Data(0), Size(0), Policy(p) {}
99 
101  {
104  }
105 
107  {
108  return Policy.GetCapacity();
109  }
110 
112  {
115  Data = 0;
116  Size = 0;
117  Policy.SetCapacity(0);
118  }
119 
120  void Reserve(UPInt newCapacity)
121  {
122  if (Policy.NeverShrinking() && newCapacity < GetCapacity())
123  return;
124 
125  if (newCapacity < Policy.GetMinCapacity())
126  newCapacity = Policy.GetMinCapacity();
127 
128  // Resize the buffer.
129  if (newCapacity == 0)
130  {
131  if (Data)
132  {
134  Data = 0;
135  }
136  Policy.SetCapacity(0);
137  }
138  else
139  {
140  UPInt gran = Policy.GetGranularity();
141  newCapacity = (newCapacity + gran - 1) / gran * gran;
142  if (Data)
143  {
144  if (Allocator::IsMovable())
145  {
146  Data = (T*)Allocator::Realloc(Data, sizeof(T) * newCapacity);
147  }
148  else
149  {
150  T* newData = (T*)Allocator::Alloc(sizeof(T) * newCapacity);
151  UPInt i, s;
152  s = (Size < newCapacity) ? Size : newCapacity;
153  for (i = 0; i < s; ++i)
154  {
155  Allocator::Construct(&newData[i], Data[i]);
157  }
158  for (i = s; i < Size; ++i)
159  {
161  }
163  Data = newData;
164  }
165  }
166  else
167  {
168  Data = (T*)Allocator::Alloc(sizeof(T) * newCapacity);
169  //memset(Buffer, 0, (sizeof(ValueType) * newSize)); // Do we need this?
170  }
171  Policy.SetCapacity(newCapacity);
172  // OVR_ASSERT(Data); // need to throw (or something) on alloc failure!
173  }
174  }
175 
176  // This version of Resize DOES NOT construct the elements.
177  // It's done to optimize PushBack, which uses a copy constructor
178  // instead of the default constructor and assignment
179  void ResizeNoConstruct(UPInt newSize)
180  {
181  UPInt oldSize = Size;
182 
183  if (newSize < oldSize)
184  {
185  Allocator::DestructArray(Data + newSize, oldSize - newSize);
186  if (newSize < (Policy.GetCapacity() >> 1))
187  {
188  Reserve(newSize);
189  }
190  }
191  else if(newSize >= Policy.GetCapacity())
192  {
193  Reserve(newSize + (newSize >> 2));
194  }
196  // array may use this array and may traverse it during Reserve (in the case, if
197  // collection occurs because of heap limit exceeded).
198  Size = newSize;
199  }
200 
203  SizePolicy Policy;
204 };
205 
206 
207 
208 //-----------------------------------------------------------------------------------
209 // ***** ArrayData
210 //
211 // General purpose array data.
212 // For internal use only in Array, ArrayLH, ArrayPOD and so on.
213 template<class T, class Allocator, class SizePolicy>
214 struct ArrayData : ArrayDataBase<T, Allocator, SizePolicy>
215 {
216  typedef T ValueType;
218  typedef SizePolicy SizePolicyType;
221 
223  : BaseType() { }
224 
226  : BaseType() { Resize(size); }
227 
228  ArrayData(const SelfType& a)
229  : BaseType(a.Policy) { Append(a.Data, a.Size); }
230 
231 
232  void Resize(UPInt newSize)
233  {
234  UPInt oldSize = this->Size;
236  if(newSize > oldSize)
237  Allocator::ConstructArray(this->Data + oldSize, newSize - oldSize);
238  }
239 
240  void PushBack(const ValueType& val)
241  {
243  Allocator::Construct(this->Data + this->Size - 1, val);
244  }
245 
246  template<class S>
247  void PushBackAlt(const S& val)
248  {
250  Allocator::ConstructAlt(this->Data + this->Size - 1, val);
251  }
252 
253  // Append the given data to the array.
254  void Append(const ValueType other[], UPInt count)
255  {
256  if (count)
257  {
258  UPInt oldSize = this->Size;
259  BaseType::ResizeNoConstruct(this->Size + count);
260  Allocator::ConstructArray(this->Data + oldSize, count, other);
261  }
262  }
263 };
264 
265 
266 
267 //-----------------------------------------------------------------------------------
268 // ***** ArrayDataCC
269 //
270 // A modification of ArrayData that always copy-constructs new elements
271 // using a specified DefaultValue. For internal use only in ArrayCC.
272 template<class T, class Allocator, class SizePolicy>
273 struct ArrayDataCC : ArrayDataBase<T, Allocator, SizePolicy>
274 {
275  typedef T ValueType;
277  typedef SizePolicy SizePolicyType;
280 
281  ArrayDataCC(const ValueType& defval)
282  : BaseType(), DefaultValue(defval) { }
283 
284  ArrayDataCC(const ValueType& defval, UPInt size)
285  : BaseType(), DefaultValue(defval) { Resize(size); }
286 
289 
290 
291  void Resize(UPInt newSize)
292  {
293  UPInt oldSize = this->Size;
295  if(newSize > oldSize)
296  Allocator::ConstructArray(this->Data + oldSize, newSize - oldSize, DefaultValue);
297  }
298 
299  void PushBack(const ValueType& val)
300  {
302  Allocator::Construct(this->Data + this->Size - 1, val);
303  }
304 
305  template<class S>
306  void PushBackAlt(const S& val)
307  {
309  Allocator::ConstructAlt(this->Data + this->Size - 1, val);
310  }
311 
312  // Append the given data to the array.
313  void Append(const ValueType other[], UPInt count)
314  {
315  if (count)
316  {
317  UPInt oldSize = this->Size;
318  BaseType::ResizeNoConstruct(this->Size + count);
319  Allocator::ConstructArray(this->Data + oldSize, count, other);
320  }
321  }
322 
324 };
325 
326 
327 
328 
329 
330 //-----------------------------------------------------------------------------------
331 // ***** ArrayBase
332 //
333 // Resizable array. The behavior can be POD (suffix _POD) and
334 // Movable (no suffix) depending on the allocator policy.
335 // In case of _POD the constructors and destructors are not called.
336 //
337 // Arrays can't handle non-movable objects! Don't put anything in here
338 // that can't be moved around by bitwise copy.
339 //
340 // The addresses of elements are not persistent! Don't keep the address
341 // of an element; the array contents will move around as it gets resized.
342 template<class ArrayData>
344 {
345 public:
346  typedef typename ArrayData::ValueType ValueType;
350 
351 
352 #undef new
354 // Redefine operator 'new' if necessary.
355 #if defined(OVR_DEFINE_NEW)
356 #define new OVR_DEFINE_NEW
357 #endif
358 
359 
361  : Data() {}
363  : Data(size) {}
364  ArrayBase(const SelfType& a)
365  : Data(a.Data) {}
366 
367  ArrayBase(const ValueType& defval)
368  : Data(defval) {}
369  ArrayBase(const ValueType& defval, UPInt size)
370  : Data(defval, size) {}
371 
373  void SetSizePolicy(const SizePolicyType& p) { Data.Policy = p; }
374 
375  bool NeverShrinking()const { return Data.Policy.NeverShrinking(); }
376  UPInt GetSize() const { return Data.Size; }
377  bool IsEmpty() const { return Data.Size == 0; }
378  UPInt GetCapacity() const { return Data.GetCapacity(); }
379  UPInt GetNumBytes() const { return Data.GetCapacity() * sizeof(ValueType); }
380 
382  void Clear() { Data.Resize(0); }
383  void Resize(UPInt newSize) { Data.Resize(newSize); }
384 
385  // Reserve can only increase the capacity
386  void Reserve(UPInt newCapacity)
387  {
388  if (newCapacity > Data.GetCapacity())
389  Data.Reserve(newCapacity);
390  }
391 
392  // Basic access.
394  {
395  OVR_ASSERT(index < Data.Size);
396  return Data.Data[index];
397  }
398  const ValueType& At(UPInt index) const
399  {
400  OVR_ASSERT(index < Data.Size);
401  return Data.Data[index];
402  }
403 
405  {
406  OVR_ASSERT(index < Data.Size);
407  return Data.Data[index];
408  }
409 
410  // Basic access.
412  {
413  OVR_ASSERT(index < Data.Size);
414  return Data.Data[index];
415  }
417  {
418  OVR_ASSERT(index < Data.Size);
419  return Data.Data[index];
420  }
421 
422  // Raw pointer to the data. Use with caution!
423  const ValueType* GetDataPtr() const { return Data.Data; }
424  ValueType* GetDataPtr() { return Data.Data; }
425 
426  // Insert the given element at the end of the array.
427  void PushBack(const ValueType& val)
428  {
429  // DO NOT pass elements of your own vector into
430  // push_back()! Since we're using references,
431  // resize() may munge the element storage!
432  // OVR_ASSERT(&val < &Buffer[0] || &val > &Buffer[BufferSize]);
433  Data.PushBack(val);
434  }
435 
436  template<class S>
437  void PushBackAlt(const S& val)
438  {
439  Data.PushBackAlt(val);
440  }
441 
442  // Remove the last element.
443  void PopBack(UPInt count = 1)
444  {
445  OVR_ASSERT(Data.Size >= count);
446  Data.Resize(Data.Size - count);
447  }
448 
450  {
452  return Back();
453  }
454 
456  {
457  ValueType t = Back();
458  PopBack();
459  return t;
460  }
461 
462 
463  // Access the first element.
464  ValueType& Front() { return At(0); }
465  const ValueType& Front() const { return At(0); }
466 
467  // Access the last element.
468  ValueType& Back() { return At(Data.Size - 1); }
469  const ValueType& Back() const { return At(Data.Size - 1); }
470 
471  // Array copy. Copies the contents of a into this array.
472  const SelfType& operator = (const SelfType& a)
473  {
474  Resize(a.GetSize());
475  for (UPInt i = 0; i < Data.Size; i++) {
476  *(Data.Data + i) = a[i];
477  }
478  return *this;
479  }
480 
481  // Removing multiple elements from the array.
483  {
484  OVR_ASSERT(index + num <= Data.Size);
485  if (Data.Size == num)
486  {
487  Clear();
488  }
489  else
490  {
491  AllocatorType::DestructArray(Data.Data + index, num);
492  AllocatorType::CopyArrayForward(
493  Data.Data + index,
494  Data.Data + index + num,
495  Data.Size - num - index);
496  Data.Size -= num;
497  }
498  }
499 
500  // Removing an element from the array is an expensive operation!
501  // It compacts only after removing the last element.
502  // If order of elements in the array is not important then use
503  // RemoveAtUnordered, that could be much faster than the regular
504  // RemoveAt.
506  {
507  OVR_ASSERT(index < Data.Size);
508  if (Data.Size == 1)
509  {
510  Clear();
511  }
512  else
513  {
515  AllocatorType::CopyArrayForward(
516  Data.Data + index,
517  Data.Data + index + 1,
518  Data.Size - 1 - index);
519  --Data.Size;
520  }
521  }
522 
523  // Removes an element from the array without respecting of original order of
524  // elements for better performance. Do not use on array where order of elements
525  // is important, otherwise use it instead of regular RemoveAt().
527  {
528  OVR_ASSERT(index < Data.Size);
529  if (Data.Size == 1)
530  {
531  Clear();
532  }
533  else
534  {
535  // copy the last element into the 'index' position
536  // and decrement the size (instead of moving all elements
537  // in [index + 1 .. size - 1] range).
538  const UPInt lastElemIndex = Data.Size - 1;
539  if (index < lastElemIndex)
540  {
542  AllocatorType::Construct(Data.Data + index, Data.Data[lastElemIndex]);
543  }
544  AllocatorType::Destruct(Data.Data + lastElemIndex);
545  --Data.Size;
546  }
547  }
548 
549  // Insert the given object at the given index shifting all the elements up.
550  void InsertAt(UPInt index, const ValueType& val = ValueType())
551  {
552  OVR_ASSERT(index <= Data.Size);
553 
554  Data.Resize(Data.Size + 1);
555  if (index < Data.Size - 1)
556  {
557  AllocatorType::CopyArrayBackward(
558  Data.Data + index + 1,
559  Data.Data + index,
560  Data.Size - 1 - index);
561  }
562  AllocatorType::Construct(Data.Data + index, val);
563  }
564 
565  // Insert the given object at the given index shifting all the elements up.
566  void InsertMultipleAt(UPInt index, UPInt num, const ValueType& val = ValueType())
567  {
568  OVR_ASSERT(index <= Data.Size);
569 
570  Data.Resize(Data.Size + num);
571  if (index < Data.Size - num)
572  {
573  AllocatorType::CopyArrayBackward(
574  Data.Data + index + num,
575  Data.Data + index,
576  Data.Size - num - index);
577  }
578  for (UPInt i = 0; i < num; ++i)
579  AllocatorType::Construct(Data.Data + index + i, val);
580  }
581 
582  // Append the given data to the array.
583  void Append(const SelfType& other)
584  {
585  Append(other.Data.Data, other.GetSize());
586  }
587 
588  // Append the given data to the array.
589  void Append(const ValueType other[], UPInt count)
590  {
591  Data.Append(other, count);
592  }
593 
594  class Iterator
595  {
598 
599  public:
600  Iterator() : pArray(0), CurIndex(-1) {}
601  Iterator(SelfType* parr, SPInt idx = 0) : pArray(parr), CurIndex(idx) {}
602 
603  bool operator==(const Iterator& it) const { return pArray == it.pArray && CurIndex == it.CurIndex; }
604  bool operator!=(const Iterator& it) const { return pArray != it.pArray || CurIndex != it.CurIndex; }
605 
607  {
608  if (pArray)
609  {
610  if (CurIndex < (SPInt)pArray->GetSize())
611  ++CurIndex;
612  }
613  return *this;
614  }
616  {
617  Iterator it(*this);
618  operator++();
619  return it;
620  }
622  {
623  if (pArray)
624  {
625  if (CurIndex >= 0)
626  --CurIndex;
627  }
628  return *this;
629  }
631  {
632  Iterator it(*this);
633  operator--();
634  return it;
635  }
636  Iterator operator+(int delta) const
637  {
638  return Iterator(pArray, CurIndex + delta);
639  }
640  Iterator operator-(int delta) const
641  {
642  return Iterator(pArray, CurIndex - delta);
643  }
644  SPInt operator-(const Iterator& right) const
645  {
646  OVR_ASSERT(pArray == right.pArray);
647  return CurIndex - right.CurIndex;
648  }
649  ValueType& operator*() const { OVR_ASSERT(pArray); return (*pArray)[CurIndex]; }
650  ValueType* operator->() const { OVR_ASSERT(pArray); return &(*pArray)[CurIndex]; }
651  ValueType* GetPtr() const { OVR_ASSERT(pArray); return &(*pArray)[CurIndex]; }
652 
653  bool IsFinished() const { return !pArray || CurIndex < 0 || CurIndex >= (int)pArray->GetSize(); }
654 
655  void Remove()
656  {
657  if (!IsFinished())
659  }
660 
661  SPInt GetIndex() const { return CurIndex; }
662  };
663 
664  Iterator Begin() { return Iterator(this); }
665  Iterator End() { return Iterator(this, (SPInt)GetSize()); }
666  Iterator Last() { return Iterator(this, (SPInt)GetSize() - 1); }
667 
669  {
670  const SelfType* pArray;
672 
673  public:
675  ConstIterator(const SelfType* parr, SPInt idx = 0) : pArray(parr), CurIndex(idx) {}
676 
677  bool operator==(const ConstIterator& it) const { return pArray == it.pArray && CurIndex == it.CurIndex; }
678  bool operator!=(const ConstIterator& it) const { return pArray != it.pArray || CurIndex != it.CurIndex; }
679 
681  {
682  if (pArray)
683  {
684  if (CurIndex < (int)pArray->GetSize())
685  ++CurIndex;
686  }
687  return *this;
688  }
690  {
691  ConstIterator it(*this);
692  operator++();
693  return it;
694  }
696  {
697  if (pArray)
698  {
699  if (CurIndex >= 0)
700  --CurIndex;
701  }
702  return *this;
703  }
705  {
706  ConstIterator it(*this);
707  operator--();
708  return it;
709  }
710  ConstIterator operator+(int delta) const
711  {
712  return ConstIterator(pArray, CurIndex + delta);
713  }
714  ConstIterator operator-(int delta) const
715  {
716  return ConstIterator(pArray, CurIndex - delta);
717  }
718  SPInt operator-(const ConstIterator& right) const
719  {
720  OVR_ASSERT(pArray == right.pArray);
721  return CurIndex - right.CurIndex;
722  }
723  const ValueType& operator*() const { OVR_ASSERT(pArray); return (*pArray)[CurIndex]; }
724  const ValueType* operator->() const { OVR_ASSERT(pArray); return &(*pArray)[CurIndex]; }
725  const ValueType* GetPtr() const { OVR_ASSERT(pArray); return &(*pArray)[CurIndex]; }
726 
727  bool IsFinished() const { return !pArray || CurIndex < 0 || CurIndex >= (int)pArray->GetSize(); }
728 
729  SPInt GetIndex() const { return CurIndex; }
730  };
731  ConstIterator Begin() const { return ConstIterator(this); }
732  ConstIterator End() const { return ConstIterator(this, (SPInt)GetSize()); }
733  ConstIterator Last() const { return ConstIterator(this, (SPInt)GetSize() - 1); }
734 
735 protected:
737 };
738 
739 
740 
741 //-----------------------------------------------------------------------------------
742 // ***** Array
743 //
744 // General purpose array for movable objects that require explicit
745 // construction/destruction.
746 template<class T, class SizePolicy=ArrayDefaultPolicy>
747 class Array : public ArrayBase<ArrayData<T, ContainerAllocator<T>, SizePolicy> >
748 {
749 public:
750  typedef T ValueType;
752  typedef SizePolicy SizePolicyType;
755 
756  Array() : BaseType() {}
757  Array(UPInt size) : BaseType(size) {}
759  Array(const SelfType& a) : BaseType(a) {}
760  const SelfType& operator=(const SelfType& a) { BaseType::operator=(a); return *this; }
761 };
762 
763 // ***** ArrayPOD
764 //
765 // General purpose array for movable objects that DOES NOT require
766 // construction/destruction. Constructors and destructors are not called!
767 // Global heap is in use.
768 template<class T, class SizePolicy=ArrayDefaultPolicy>
769 class ArrayPOD : public ArrayBase<ArrayData<T, ContainerAllocator_POD<T>, SizePolicy> >
770 {
771 public:
772  typedef T ValueType;
774  typedef SizePolicy SizePolicyType;
777 
779  ArrayPOD(UPInt size) : BaseType(size) {}
781  ArrayPOD(const SelfType& a) : BaseType(a) {}
782  const SelfType& operator=(const SelfType& a) { BaseType::operator=(a); return *this; }
783 };
784 
785 
786 // ***** ArrayCPP
787 //
788 // General purpose, fully C++ compliant array. Can be used with non-movable data.
789 // Global heap is in use.
790 template<class T, class SizePolicy=ArrayDefaultPolicy>
791 class ArrayCPP : public ArrayBase<ArrayData<T, ContainerAllocator_CPP<T>, SizePolicy> >
792 {
793 public:
794  typedef T ValueType;
796  typedef SizePolicy SizePolicyType;
799 
801  ArrayCPP(UPInt size) : BaseType(size) {}
803  ArrayCPP(const SelfType& a) : BaseType(a) {}
804  const SelfType& operator=(const SelfType& a) { BaseType::operator=(a); return *this; }
805 };
806 
807 
808 // ***** ArrayCC
809 //
810 // A modification of the array that uses the given default value to
811 // construct the elements. The constructors and destructors are
812 // properly called, the objects must be movable.
813 
814 template<class T, class SizePolicy=ArrayDefaultPolicy>
815 class ArrayCC : public ArrayBase<ArrayDataCC<T, ContainerAllocator<T>, SizePolicy> >
816 {
817 public:
818  typedef T ValueType;
820  typedef SizePolicy SizePolicyType;
823 
824  ArrayCC(const ValueType& defval) : BaseType(defval) {}
825  ArrayCC(const ValueType& defval, UPInt size) : BaseType(defval, size) {}
826  ArrayCC(const ValueType& defval, const SizePolicyType& p) : BaseType(defval) { SetSizePolicy(p); }
827  ArrayCC(const SelfType& a) : BaseType(a) {}
828  const SelfType& operator=(const SelfType& a) { BaseType::operator=(a); return *this; }
829 };
830 
831 } // OVR
832 
833 #endif
ValueType * GetDataPtr()
Definition: OVR_Array.h:424
void SetCapacity(UPInt capacity)
Definition: OVR_Array.h:52
UPInt GetCapacity() const
Definition: OVR_Array.h:378
const SelfType & operator=(const SelfType &a)
Definition: OVR_Array.h:804
void Clear()
Definition: OVR_Array.h:382
ArrayDataCC< T, Allocator, SizePolicy > SelfType
Definition: OVR_Array.h:279
const ValueType & At(UPInt index) const
Definition: OVR_Array.h:398
ArrayData::ValueType ValueType
Definition: OVR_Array.h:346
ValueType DefaultValue
Definition: OVR_Array.h:323
void Reserve(UPInt newCapacity)
Definition: OVR_Array.h:120
ArrayBase(const ValueType &defval, UPInt size)
Definition: OVR_Array.h:369
ArrayBase< ArrayData > SelfType
Definition: OVR_Array.h:349
ArrayPOD(const SizePolicyType &p)
Definition: OVR_Array.h:780
void PushBack(const ValueType &val)
Definition: OVR_Array.h:240
Iterator operator--(int)
Definition: OVR_Array.h:630
ArrayCC(const SelfType &a)
Definition: OVR_Array.h:827
SizePolicy SizePolicyType
Definition: OVR_Array.h:820
void ResizeNoConstruct(UPInt newSize)
Definition: OVR_Array.h:179
ConstIterator Last() const
Definition: OVR_Array.h:733
void PushBack(const ValueType &val)
Definition: OVR_Array.h:427
bool NeverShrinking() const
Definition: OVR_Array.h:73
void PushBack(const ValueType &val)
Definition: OVR_Array.h:299
void InsertAt(UPInt index, const ValueType &val=ValueType())
Definition: OVR_Array.h:550
void Append(const ValueType other[], UPInt count)
Definition: OVR_Array.h:589
OVR_FORCE_INLINE T * ConstructAlt(void *p, const S &source)
const SelfType & operator=(const SelfType &a)
Definition: OVR_Array.h:472
void RemoveMultipleAt(UPInt index, UPInt num)
Definition: OVR_Array.h:482
ArrayBase(const SelfType &a)
Definition: OVR_Array.h:364
Array(const SizePolicyType &p)
Definition: OVR_Array.h:758
Allocator AllocatorType
Definition: OVR_Array.h:90
Array< T, SizePolicy > SelfType
Definition: OVR_Array.h:753
const SelfType & operator=(const SelfType &a)
Definition: OVR_Array.h:782
ArrayPOD(UPInt size)
Definition: OVR_Array.h:779
const SelfType & operator=(const SelfType &a)
Definition: OVR_Array.h:828
ArrayDefaultPolicy(const ArrayDefaultPolicy &)
Definition: OVR_Array.h:45
Iterator End()
Definition: OVR_Array.h:665
ValueType & operator*() const
Definition: OVR_Array.h:649
Allocator AllocatorType
Definition: OVR_Array.h:217
UPInt GetCapacity() const
Definition: OVR_Array.h:106
ArrayDataBase< T, Allocator, SizePolicy > BaseType
Definition: OVR_Array.h:278
SPInt GetIndex() const
Definition: OVR_Array.h:661
UPInt GetNumBytes() const
Definition: OVR_Array.h:379
SizePolicy Policy
Definition: OVR_Array.h:203
ContainerAllocator_CPP< T > AllocatorType
Definition: OVR_Array.h:795
bool operator==(const Iterator &it) const
Definition: OVR_Array.h:603
void PushBackAlt(const S &val)
Definition: OVR_Array.h:247
Iterator operator-(int delta) const
Definition: OVR_Array.h:640
OVR_FORCE_INLINE void ConstructArray(void *p, UPInt count)
SizePolicy SizePolicyType
Definition: OVR_Array.h:91
ArrayData::AllocatorType AllocatorType
Definition: OVR_Array.h:347
void Append(const ValueType other[], UPInt count)
Definition: OVR_Array.h:313
ArrayData< T, Allocator, SizePolicy > SelfType
Definition: OVR_Array.h:220
Array(const SelfType &a)
Definition: OVR_Array.h:759
size_t UPInt
Definition: OVR_Types.h:218
ArrayConstPolicy(const SelfType &)
Definition: OVR_Array.h:69
ArrayData::SizePolicyType SizePolicyType
Definition: OVR_Array.h:348
void Resize(UPInt newSize)
Definition: OVR_Array.h:232
bool NeverShrinking() const
Definition: OVR_Array.h:49
ArrayPOD< T, SizePolicy > SelfType
Definition: OVR_Array.h:775
OVR_FORCE_INLINE T * Construct(void *p)
ConstIterator(const SelfType *parr, SPInt idx=0)
Definition: OVR_Array.h:675
void RemoveAtUnordered(UPInt index)
Definition: OVR_Array.h:526
ArrayDataBase< T, Allocator, SizePolicy > SelfType
Definition: OVR_Array.h:92
ArrayPOD(const SelfType &a)
Definition: OVR_Array.h:781
SizePolicyType * GetSizePolicy() const
Definition: OVR_Array.h:372
ConstIterator operator-(int delta) const
Definition: OVR_Array.h:714
void PushBackAlt(const S &val)
Definition: OVR_Array.h:437
ArrayBase(UPInt size)
Definition: OVR_Array.h:362
SizePolicy SizePolicyType
Definition: OVR_Array.h:774
bool operator==(const ConstIterator &it) const
Definition: OVR_Array.h:677
void PopBack(UPInt count=1)
Definition: OVR_Array.h:443
bool NeverShrinking() const
Definition: OVR_Array.h:375
ArrayData(UPInt size)
Definition: OVR_Array.h:225
const SelfType & operator=(const SelfType &a)
Definition: OVR_Array.h:760
const ValueType * GetDataPtr() const
Definition: OVR_Array.h:423
const ValueType * GetPtr() const
Definition: OVR_Array.h:725
Allocator AllocatorType
Definition: OVR_Array.h:276
ArrayCPP(UPInt size)
Definition: OVR_Array.h:801
ArrayBase< ArrayDataCC< T, ContainerAllocator< T >, SizePolicy > > BaseType
Definition: OVR_Array.h:822
SizePolicy SizePolicyType
Definition: OVR_Array.h:218
SizePolicy SizePolicyType
Definition: OVR_Array.h:796
const ValueType & Back() const
Definition: OVR_Array.h:469
UPInt GetSize() const
Definition: OVR_Array.h:376
ConstIterator operator+(int delta) const
Definition: OVR_Array.h:710
Iterator Last()
Definition: OVR_Array.h:666
ArrayDataCC(const ValueType &defval)
Definition: OVR_Array.h:281
ArrayCPP(const SizePolicyType &p)
Definition: OVR_Array.h:802
ValueType & Front()
Definition: OVR_Array.h:464
Iterator & operator--()
Definition: OVR_Array.h:621
ArrayData Data
Definition: OVR_Array.h:736
UPInt GetMinCapacity() const
Definition: OVR_Array.h:47
void Resize(UPInt newSize)
Definition: OVR_Array.h:383
#define OVR_ASSERT(p)
ConstIterator End() const
Definition: OVR_Array.h:732
ArrayCPP< T, SizePolicy > SelfType
Definition: OVR_Array.h:797
ArrayCC(const ValueType &defval, UPInt size)
Definition: OVR_Array.h:825
bool operator!=(const ConstIterator &it) const
Definition: OVR_Array.h:678
const ValueType * operator->() const
Definition: OVR_Array.h:724
ValueType ValueAt(UPInt index) const
Definition: OVR_Array.h:404
ArrayBase(const ValueType &defval)
Definition: OVR_Array.h:367
ValueType & Back()
Definition: OVR_Array.h:468
virtual void * Realloc(void *p, UPInt newSize)=0
#define OVR_MEMORY_REDEFINE_NEW(class_name)
Definition: OVR_Allocator.h:91
Iterator(SelfType *parr, SPInt idx=0)
Definition: OVR_Array.h:601
ArrayCC< T, SizePolicy > SelfType
Definition: OVR_Array.h:821
ArrayDataCC(const ValueType &defval, UPInt size)
Definition: OVR_Array.h:284
ArrayCC(const ValueType &defval)
Definition: OVR_Array.h:824
ConstIterator & operator--()
Definition: OVR_Array.h:695
SizePolicy SizePolicyType
Definition: OVR_Array.h:752
ValueType * Data
Definition: OVR_Array.h:201
ContainerAllocator< T > AllocatorType
Definition: OVR_Array.h:819
ValueType * operator->() const
Definition: OVR_Array.h:650
ArrayData(const SelfType &a)
Definition: OVR_Array.h:228
ValueType Pop()
Definition: OVR_Array.h:455
bool operator!=(const Iterator &it) const
Definition: OVR_Array.h:604
UPInt GetCapacity() const
Definition: OVR_Array.h:75
bool IsEmpty() const
Definition: OVR_Array.h:377
void ClearAndRelease()
Definition: OVR_Array.h:381
ValueType & operator[](UPInt index)
Definition: OVR_Array.h:411
void Append(const SelfType &other)
Definition: OVR_Array.h:583
void RemoveAt(UPInt index)
Definition: OVR_Array.h:505
SizePolicy SizePolicyType
Definition: OVR_Array.h:277
Iterator operator+(int delta) const
Definition: OVR_Array.h:636
SPInt operator-(const ConstIterator &right) const
Definition: OVR_Array.h:718
ConstIterator operator--(int)
Definition: OVR_Array.h:704
UPInt GetGranularity() const
Definition: OVR_Array.h:72
const ValueType & Front() const
Definition: OVR_Array.h:465
void Append(const ValueType other[], UPInt count)
Definition: OVR_Array.h:254
ValueType & At(UPInt index)
Definition: OVR_Array.h:393
UPInt GetCapacity() const
Definition: OVR_Array.h:51
ptrdiff_t SPInt
Definition: OVR_Types.h:219
UPInt GetGranularity() const
Definition: OVR_Array.h:48
ArrayDataBase< T, Allocator, SizePolicy > BaseType
Definition: OVR_Array.h:219
virtual void * Alloc(UPInt size)=0
ConstIterator Begin() const
Definition: OVR_Array.h:731
ArrayConstPolicy< MinCapacity, Granularity, NeverShrink > SelfType
Definition: OVR_Array.h:66
ValueType * GetPtr() const
Definition: OVR_Array.h:651
Iterator operator++(int)
Definition: OVR_Array.h:615
ArrayBase< ArrayData< T, ContainerAllocator< T >, SizePolicy > > BaseType
Definition: OVR_Array.h:754
UPInt GetMinCapacity() const
Definition: OVR_Array.h:71
OVR_FORCE_INLINE void Destruct(T *pobj)
int char * index(const char *__s, int __c) __THROW __attribute_pure__ __nonnull((1))
void Resize(UPInt newSize)
Definition: OVR_Array.h:291
const SelfType * pArray
Definition: OVR_Array.h:670
ArrayBase< ArrayData< T, ContainerAllocator_POD< T >, SizePolicy > > BaseType
Definition: OVR_Array.h:776
void PushBackAlt(const S &val)
Definition: OVR_Array.h:306
SPInt operator-(const Iterator &right) const
Definition: OVR_Array.h:644
ValueType & PushDefault()
Definition: OVR_Array.h:449
ConstIterator & operator++()
Definition: OVR_Array.h:680
void ClearAndRelease()
Definition: OVR_Array.h:111
ConstIterator operator++(int)
Definition: OVR_Array.h:689
const ValueType & operator*() const
Definition: OVR_Array.h:723
Iterator Begin()
Definition: OVR_Array.h:664
OVR_FORCE_INLINE void DestructArray(T *pobj, UPInt count)
virtual void Free(void *p)=0
void Reserve(UPInt newCapacity)
Definition: OVR_Array.h:386
ArrayCPP(const SelfType &a)
Definition: OVR_Array.h:803
void InsertMultipleAt(UPInt index, UPInt num, const ValueType &val=ValueType())
Definition: OVR_Array.h:566
ArrayBase< ArrayData< T, ContainerAllocator_CPP< T >, SizePolicy > > BaseType
Definition: OVR_Array.h:798
void SetCapacity(UPInt capacity)
Definition: OVR_Array.h:76
bool IsFinished() const
Definition: OVR_Array.h:653
ArrayDataBase(const SizePolicy &p)
Definition: OVR_Array.h:97
ArrayCC(const ValueType &defval, const SizePolicyType &p)
Definition: OVR_Array.h:826
void SetSizePolicy(const SizePolicyType &p)
Definition: OVR_Array.h:373
ContainerAllocator< T > AllocatorType
Definition: OVR_Array.h:751
Iterator & operator++()
Definition: OVR_Array.h:606
Array(UPInt size)
Definition: OVR_Array.h:757
ContainerAllocator_POD< T > AllocatorType
Definition: OVR_Array.h:773
ArrayDataCC(const SelfType &a)
Definition: OVR_Array.h:287