MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / Array

Class Array

include/reactphysics3d/containers/Array.h:44–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 */
43template<typename T>
44class Array {
45
46 private:
47
48 // -------------------- Attributes -------------------- //
49
50 /// Buffer for the array elements
51 T* mBuffer;
52
53 /// Number of elements in the array
54 uint64 mSize;
55
56 /// Number of allocated elements in the array
57 uint64 mCapacity;
58
59 /// Memory allocator
60 MemoryAllocator& mAllocator;
61
62 public:
63
64 /// Class Iterator
65 /**
66 * This class represents an iterator for the array
67 */
68 class Iterator {
69
70 private:
71
72 uint64 mCurrentIndex;
73 T* mBuffer;
74 uint64 mSize;
75
76 public:
77
78 // Iterator traits
79 using value_type = T;
80 using difference_type = std::ptrdiff_t;
81 using pointer = T*;
82 using const_pointer = T const*;
83 using reference = T&;
84 using const_reference = const T&;
85 using iterator_category = std::random_access_iterator_tag;
86
87 /// Constructor
88 Iterator() = default;
89
90 /// Constructor
91 Iterator(void* buffer, uint64 index, uint64 size)
92 :mCurrentIndex(index), mBuffer(static_cast<T*>(buffer)), mSize(size) {
93
94 }
95
96 /// Deferencable
97 reference operator*() {
98 assert(mCurrentIndex < mSize);
99 return mBuffer[mCurrentIndex];
100 }
101

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected