Go to the documentation of this file.
43 void remove(
unsigned index)
48 void trim(
size_t newSize,
bool reallocate)
54 auto newmem = realloc(
values,
sizeof(T) * newSize);
55 if(newmem ==
nullptr) {
77 template <
typename T>
struct ObjectList :
public ScalarList<T*> {
88 template <
typename U = T>
89 typename std::enable_if<std::is_copy_constructible<U>::value,
Element&>::type
operator=(
const U& v)
111 while(this->
size != 0) {
117 bool insert(
unsigned index,
const T& value)
119 auto el =
new T(value);
126 void remove(
unsigned index)
128 delete this->
values[index];
133 void trim(
size_t newSize,
bool reallocate)
135 for(
unsigned i = this->
size; i > newSize; --i) {
136 delete this->
values[i - 1];
137 this->
values[i - 1] =
nullptr;
145 return Element{this->
values[index]};
150 return *this->
values[index];
156 if(newSize <= size) {
160 auto newmem = realloc(values,
sizeof(T) * newSize);
161 if(newmem ==
nullptr) {
165 values =
static_cast<T*
>(newmem);
172 auto curSize = this->size;
177 std::fill_n(&this->values[curSize], newSize - curSize,
nullptr);
181 template <
typename T>
T * values
Definition: WiringList.h:35
bool allocate(size_t newSize)
Definition: WiringList.h:178
void trim(size_t newSize, bool reallocate)
Definition: WiringList.h:141
List of object pointers.
Definition: WiringList.h:85
void remove(unsigned index)
Definition: WiringList.h:59
typename std::conditional< std::is_scalar< T >::value, ScalarList< T >, ObjectList< T > >::type List
Definition: WiringList.h:190
bool allocate(size_t newSize)
Definition: WiringList.h:162
Definition: WiringList.h:13
Element & operator=(T *v)
Definition: WiringList.h:89
void remove(unsigned index)
Definition: WiringList.h:134
bool insert(unsigned index, const T &value)
Definition: WiringList.h:125
void clear()
Definition: WiringList.h:117
List of scalar values.
Definition: WiringList.h:26
Element operator[](unsigned index)
Definition: WiringList.h:151
~ScalarList()
Definition: WiringList.h:38
T *& value
Definition: WiringList.h:87
~ObjectList()
Definition: WiringList.h:110
size_t size
Definition: WiringList.h:36
bool insert(unsigned index, T value)
Definition: WiringList.h:52
T & operator[](unsigned index)
Definition: WiringList.h:79
void clear()
Definition: WiringList.h:45
void trim(size_t newSize, bool reallocate)
Definition: WiringList.h:64
Definition: WiringList.h:86