19 #ifndef OST_POD_VECTOR_HH
20 #define OST_POD_VECTOR_HH
40 PodVector(): begin_(NULL), end_(NULL), capacity_(NULL) {}
44 this->raw_set(rhs.
data(), rhs.
size());
76 size_t capacity()
const {
return capacity_-begin_; }
77 size_t size()
const {
return end_-begin_; }
90 if (end_>=capacity_) {
91 this->do_reserve(this->capacity()*2);
108 void reserve(
size_t n)
110 return do_reserve(n);
115 return begin_[index];
119 return begin_[index];
123 const T*
data()
const {
return begin_; }
125 void raw_set(T* data,
size_t n)
128 memcpy(begin_, data,
sizeof(T)*n);
132 void do_reserve(
size_t n);
135 value_type* capacity_;
138 template <
typename T>
139 void PodVector<T>::do_reserve(
size_t n)
141 size_t old_size=this->size();
143 if (n==this->capacity()) {
146 begin_=
reinterpret_cast<T*
>(realloc(begin_, n*
sizeof(T)));
147 end_=begin_+old_size;