MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/PositionBasedDynamics / ObjectArray

Class ObjectArray

Utils/ObjectArray.h:10–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8{
9 template <class T, int growBy = 100, bool linearGrow = true>
10 class ObjectArray
11 {
12 private:
13 unsigned int m_size;
14 unsigned int m_capacity;
15 T* m_data;
16
17 protected:
18 FORCE_INLINE void init()
19 {
20 m_size = 0u;
21 m_capacity = 0u;
22 m_data = 0;
23 }
24
25 public:
26 FORCE_INLINE ObjectArray()
27 {
28 init();
29 }
30
31 FORCE_INLINE ObjectArray(const ObjectArray& other)
32 {
33 init();
34 *this = other;
35 }
36
37 ~ObjectArray()
38 {
39 clear();
40 }
41
42 /** Return the pointer of the data.
43 */
44 FORCE_INLINE T* arrayPointer()
45 {
46 return m_data;
47 }
48
49 /** Return the pointer of the data.
50 */
51 FORCE_INLINE const T* arrayPointer() const
52 {
53 return m_data;
54 }
55
56 /** Set size to zero but do not change capacity.
57 */
58 FORCE_INLINE void reset()
59 {
60 m_size = 0u;
61 }
62
63 FORCE_INLINE void clear()
64 {
65 delete [] m_data;
66 init();
67 }

Callers

nothing calls this directly

Calls 1

resizeMethod · 0.95

Tested by

no test coverage detected