39 template<
class T>
class v_array
118 void push(
const T &new_elem);
126 void push_many(
const T* new_elem,
size_t num);
171 size_t new_length = 2 * old_length + 3;
173 begin = SG_REALLOC(T, begin, old_length, new_length);
174 end = begin + old_length;
188 begin = SG_REALLOC(T, begin, length, new_length);
192 memcpy(
end, new_elem, num *
sizeof(T));
200 begin = SG_REALLOC(T, begin, old_length, length);
201 if (old_length < length)
202 memset(begin + old_length, 0, (length - old_length)*
sizeof(T));
211 begin = SG_CALLOC(T, length);
219 if (stack.end != stack.begin)
220 return *(--stack.end);
void reserve(size_t length)
T * end
Pointer to last set element in the array.
T * begin
Pointer to first element of the array.
void push_many(const T *new_elem, size_t num)
Class v_array taken directly from JL's implementation.
void push(const T &new_elem)
T * end_array
Pointer to end of array, based on memory reserved.
static T max(T a, T b)
return the maximum of two integers
T & operator[](unsigned int i)
all of classes and functions are contained in the shogun namespace
void calloc_reserve(size_t length)