MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / Array

Class Array

physx/source/foundation/include/PsArray.h:57–634  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55*/
56template <class T, class Alloc = typename AllocatorTraits<T>::Type>
57class Array : protected Alloc
58{
59 public:
60 typedef T* Iterator;
61 typedef const T* ConstIterator;
62
63 explicit Array(const PxEMPTY v) : Alloc(v)
64 {
65 if(mData)
66 mCapacity |= PX_SIGN_BITMASK;
67 }
68
69 /*!
70 Default array constructor. Initialize an empty array
71 */
72 PX_INLINE explicit Array(const Alloc& alloc = Alloc()) : Alloc(alloc), mData(0), mSize(0), mCapacity(0)
73 {
74 }
75
76 /*!
77 Initialize array with given capacity
78 */
79 PX_INLINE explicit Array(uint32_t size, const T& a = T(), const Alloc& alloc = Alloc())
80 : Alloc(alloc), mData(0), mSize(0), mCapacity(0)
81 {
82 resize(size, a);
83 }
84
85 /*!
86 Copy-constructor. Copy all entries from other array
87 */
88 template <class A>
89 PX_INLINE explicit Array(const Array<T, A>& other, const Alloc& alloc = Alloc())
90 : Alloc(alloc)
91 {
92 copy(other);
93 }
94
95 // This is necessary else the basic default copy constructor is used in the case of both arrays being of the same
96 // template instance
97 // The C++ standard clearly states that a template constructor is never a copy constructor [2]. In other words,
98 // the presence of a template constructor does not suppress the implicit declaration of the copy constructor.
99 // Also never make a copy constructor explicit, or copy-initialization* will no longer work. This is because
100 // 'binding an rvalue to a const reference requires an accessible copy constructor' (http://gcc.gnu.org/bugs/)
101 // *http://stackoverflow.com/questions/1051379/is-there-a-difference-in-c-between-copy-initialization-and-assignment-initializ
102 PX_INLINE Array(const Array& other, const Alloc& alloc = Alloc()) : Alloc(alloc)
103 {
104 copy(other);
105 }
106
107 /*!
108 Initialize array with given length
109 */
110 PX_INLINE explicit Array(const T* first, const T* last, const Alloc& alloc = Alloc())
111 : Alloc(alloc), mSize(last < first ? 0 : uint32_t(last - first)), mCapacity(mSize)
112 {
113 mData = allocate(mSize);
114 copy(mData, mData + mSize, first);

Callers 2

underscore.jsFile · 0.50
newNodeFunction · 0.50

Calls 3

copyFunction · 0.85
TFunction · 0.85
clearFunction · 0.50

Tested by

no test coverage detected