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) {
59 values =
static_cast<T*
>(newmem);
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;
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>
typename std::conditional< std::is_scalar< T >::value, ScalarList< T >, ObjectList< T > >::type List
Definition: WiringList.h:182
~ScalarList()
Definition: WiringList.h:22
Definition: WiringList.h:13
List of object pointers.
Definition: WiringList.h:77
const T & operator[](unsigned index) const
Definition: WiringList.h:68
bool insert(unsigned index, T value)
Definition: WiringList.h:36
void remove(unsigned index)
Definition: WiringList.h:43
size_t size
Definition: WiringList.h:20
T * values
Definition: WiringList.h:19
void trim(size_t newSize, bool reallocate)
Definition: WiringList.h:48
~ObjectList()
Definition: WiringList.h:102
Element operator[](unsigned index)
Definition: WiringList.h:143
std::enable_if< std::is_copy_constructible< U >::value, Element & >::type operator=(const U &v)
Definition: WiringList.h:89
bool allocate(size_t newSize)
Definition: WiringList.h:154
Definition: WiringList.h:78
bool allocate(size_t newSize)
Definition: WiringList.h:170
List of scalar values.
Definition: WiringList.h:18
Element & operator=(T *v)
Definition: WiringList.h:81
T & operator[](unsigned index)
Definition: WiringList.h:63
void clear()
Definition: WiringList.h:109
void clear()
Definition: WiringList.h:29
const T & operator[](unsigned index) const
Definition: WiringList.h:148
bool insert(unsigned index, const T &value)
Definition: WiringList.h:117
void trim(size_t newSize, bool reallocate)
Definition: WiringList.h:133
T *& value
Definition: WiringList.h:79