11 #ifndef __VECTOR_HEADER
12 #define __VECTOR_HEADER
16 #include "../com/archive_enum.hpp"
26 vector(): array_((T*)malloc(sizeof(T))), size_(0) {
31 explicit vector(
size_type const &
size, T
const & val = T()): array_((T*)malloc(size * sizeof(T))), size_(size) {
36 vector(
vector const & arg): array_((T*)malloc(arg.size_ * sizeof(T))), size_(arg.size_) {
38 array_[
i] = arg.array_[
i];
52 array_ = (T*)realloc(array_, size_ * 2 *
sizeof(T));
54 ASSERT_MSG(array_ != NULL,
"no RAM for vector of this size")
62 for(; pos < size_; ++pos) {
63 if(array_[pos] == val)
74 array_[
i] = array_[
i + 1];
92 return array_[size_ - 1];
96 return array_[size_ - 1];
119 array_ = (T*)realloc(array_, new_capacity *
sizeof(T));
124 array_ = (T*)realloc(array_, size_ *
sizeof(T));
128 while(new_size > size_)
177 template<
typename Archive>
193 #endif //__VECTOR_HEADER
T const & front() const
Definition: vector.hpp:102
size_type const & end() const
Definition: vector.hpp:163
constexpr size_type begin() const
Definition: vector.hpp:160
bool empty() const
Definition: vector.hpp:134
size_type const & size() const
Definition: vector.hpp:110
#define ASSERT_MSG(exp, msg)
Definition: ard_assert.hpp:34
void push_back(T const &in)
Definition: vector.hpp:50
vector()
Definition: vector.hpp:26
void pop_back()
Definition: vector.hpp:58
size_type capacity() const
Definition: vector.hpp:113
T * data()
Definition: vector.hpp:106
Definition: vector.hpp:21
T & operator[](size_type const &pos)
Definition: vector.hpp:80
uint16_t size_type
Definition: vector.hpp:24
void print(S &os) const
Definition: vector.hpp:168
T & front()
Definition: vector.hpp:98
void resize(size_type const &new_size, T const &val=T())
Definition: vector.hpp:126
void reserve(size_type const &new_capacity)
Definition: vector.hpp:117
T const & operator[](size_type const &pos) const
Definition: vector.hpp:85
~vector()
Definition: vector.hpp:28
void clear()
Definition: vector.hpp:68
void shrink_to_fit()
Definition: vector.hpp:122
T & back()
Definition: vector.hpp:90
void serialize(Archive &ar)
Definition: vector.hpp:178
size_type find(T const &val, size_type pos=0) const
Definition: vector.hpp:61
#define F(x)
Definition: ustd_generic.hpp:15
void erase(size_type const &pos)
Definition: vector.hpp:71
vector(vector const &arg)
Definition: vector.hpp:36
vector & operator=(vector const &rhs)
Definition: vector.hpp:41
vector(size_type const &size, T const &val=T())
Definition: vector.hpp:31
T const & back() const
Definition: vector.hpp:94
T value_type
Definition: vector.hpp:23
#define ASSERT(exp)
Definition: ard_assert.hpp:33