20 #ifndef GALOIS_PODRESIZEABLEARRAY_H
21 #define GALOIS_PODRESIZEABLEARRAY_H
28 #include <type_traits>
30 #include "galois/config.h"
39 template <
typename _Tp>
60 template <
class InputIterator>
62 : data_(NULL), capacity_(0), size_(0) {
63 size_t to_add = last - first;
65 std::copy_n(first, to_add,
begin());
77 : data_(v.data_), capacity_(v.capacity_), size_(v.size_) {
91 capacity_ = v.capacity_;
127 bool empty()
const {
return size_ == 0; }
131 if (capacity_ == 0) {
134 while (capacity_ < n) {
137 data_ =
static_cast<_Tp*
>(
138 realloc(reinterpret_cast<void*>(data_), capacity_ *
sizeof(_Tp)));
154 throw std::out_of_range(
"PODResizeableArray::at");
159 throw std::out_of_range(
"PODResizeableArray::at");
164 size_t n = last - first;
166 memcpy(reinterpret_cast<void*>(data_), first, n *
sizeof(_Tp));
179 data_[size_ - 1] = value;
182 template <
class InputIterator>
184 InputIterator last) {
185 assert(position ==
end());
186 size_t old_size = size_;
187 size_t to_add = last - first;
188 resize(old_size + to_add);
189 std::copy_n(first, to_add,
begin() + old_size);
193 std::swap(data_, v.data_);
194 std::swap(size_, v.size_);
195 std::swap(capacity_, v.capacity_);
200 #endif // GALOIS_PODRESIZEABLEARRAY_H
const_reverse_iterator crbegin() const
Definition: PODResizeableArray.h:121
iterator end()
Definition: PODResizeableArray.h:107
const_reference back() const
Definition: PODResizeableArray.h:172
const_pointer data() const
Definition: PODResizeableArray.h:175
PODResizeableArray(size_t n)
Definition: PODResizeableArray.h:68
reference at(size_type __n)
Definition: PODResizeableArray.h:152
const_reverse_iterator crend() const
Definition: PODResizeableArray.h:122
void push_back(const _Tp &value)
Definition: PODResizeableArray.h:177
size_t size_type
Definition: PODResizeableArray.h:47
const_iterator end() const
Definition: PODResizeableArray.h:108
reference front()
Definition: PODResizeableArray.h:169
ptrdiff_t difference_type
Definition: PODResizeableArray.h:48
reference back()
Definition: PODResizeableArray.h:171
const value_type * const_pointer
Definition: PODResizeableArray.h:52
const_iterator cbegin() const
Definition: PODResizeableArray.h:119
size_type max_size() const
Definition: PODResizeableArray.h:126
PODResizeableArray & operator=(PODResizeableArray &&v)
move assignment operator
Definition: PODResizeableArray.h:87
void resize(size_t n)
Definition: PODResizeableArray.h:142
bool empty() const
Definition: PODResizeableArray.h:127
const_reference at(size_type __n) const
Definition: PODResizeableArray.h:157
PODResizeableArray(InputIterator first, InputIterator last)
Definition: PODResizeableArray.h:61
void insert(iterator GALOIS_USED_ONLY_IN_DEBUG(position), InputIterator first, InputIterator last)
Definition: PODResizeableArray.h:183
reference operator[](size_type __n)
Definition: PODResizeableArray.h:150
PODResizeableArray & operator=(const PODResizeableArray &)=delete
disabled (shallow) copy assignment operator
const_pointer const_iterator
Definition: PODResizeableArray.h:54
void assign(iterator first, iterator last)
Definition: PODResizeableArray.h:163
const_reverse_iterator rend() const
Definition: PODResizeableArray.h:115
const_reference front() const
Definition: PODResizeableArray.h:170
void reserve(size_t n)
Definition: PODResizeableArray.h:129
std::reverse_iterator< iterator > reverse_iterator
Definition: PODResizeableArray.h:55
void swap(PODResizeableArray &v)
Definition: PODResizeableArray.h:192
PODResizeableArray()
Definition: PODResizeableArray.h:58
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: PODResizeableArray.h:56
const_iterator cend() const
Definition: PODResizeableArray.h:120
value_type & reference
Definition: PODResizeableArray.h:49
const value_type & const_reference
Definition: PODResizeableArray.h:50
size_type size() const
Definition: PODResizeableArray.h:125
const_reverse_iterator rbegin() const
Definition: PODResizeableArray.h:111
value_type * pointer
Definition: PODResizeableArray.h:51
void clear()
Definition: PODResizeableArray.h:147
const_iterator begin() const
Definition: PODResizeableArray.h:106
~PODResizeableArray()
Definition: PODResizeableArray.h:99
pointer iterator
Definition: PODResizeableArray.h:53
_Tp value_type
Definition: PODResizeableArray.h:46
iterator begin()
Definition: PODResizeableArray.h:105
reverse_iterator rbegin()
Definition: PODResizeableArray.h:110
This is a container that encapsulates a resizeable array of plain-old-datatype (POD) elements...
Definition: PODResizeableArray.h:40
pointer data()
Definition: PODResizeableArray.h:174
const_reference operator[](size_type __n) const
Definition: PODResizeableArray.h:151
PODResizeableArray(PODResizeableArray &&v)
move constructor
Definition: PODResizeableArray.h:76
reverse_iterator rend()
Definition: PODResizeableArray.h:114