31 typedef typename std::vector<T>::iterator
iterator;
88 void append(
const std::vector<T> & vals);
101 virtual void erase(
const std::size_t num) = 0;
108 virtual void eraseChunk(
const std::size_t chunk_size) = 0;
132 virtual iterator
beginChunk(
const std::size_t chunk_size) = 0;
157 const T &
operator[](
const std::size_t index)
const;
162 void swap(std::vector<T> & in_data);
202 virtual std::size_t
newEnd(
const std::size_t new_end) = 0;
213 template <
typename T>
218 template <
typename T>
223 template <
typename T>
227 this->_end_pos = newEnd(this->_end_pos + 1);
228 this->_data[this->_end_pos - 1] =
value;
231 template <
typename T>
235 this->_end_pos = newEnd(this->_end_pos + 1);
236 this->_data[this->_end_pos - 1] = std::move(
value);
239 template <
typename T>
243 const auto additional_size = std::distance(in_begin, in_end);
244 if (additional_size == 0)
247 this->_end_pos = this->newEnd(this->_end_pos + additional_size);
248 std::copy(in_begin, in_end, this->end() - additional_size);
251 template <
typename T>
255 this->append(vals.begin(), vals.end());
258 template <
typename T>
262 this->_begin_pos = 0;
266 template <
typename T>
270 mooseAssert(this->_begin_pos + index < this->_end_pos,
"Attempt to access off end of Buffer!");
271 return this->_data[this->_begin_pos + index];
274 template <
typename T>
278 mooseAssert(this->_begin_pos + index < this->_end_pos,
"Attempt to access off end of Buffer!");
279 return this->_data[this->_begin_pos + index];
282 template <
typename T>
287 this->_begin_pos = 0;
288 this->_end_pos = this->_data.size();
virtual void eraseChunk(const std::size_t chunk_size)=0
std::size_t size() const
Get the size.
Buffer()
Create an empty buffer.
const_iterator end() const
Const iterator for the last entry in the buffer.
virtual void erase(const std::size_t num)=0
Remove the first num elements.
std::vector< T >::const_iterator const_iterator
bool empty() const
Whether or not the buffer is empty.
void swap(std::vector< T > &in_data)
Use in_data as our data vector.
void swap(std::vector< T > &data, const std::size_t idx0, const std::size_t idx1, const libMesh::Parallel::Communicator &comm)
Swap function for serial or distributed vector of data.
std::size_t _end_pos
The ending position.
void push_back(const T &value)
Add a new entry on the end.
std::size_t dataBeginPos() const
The current beginning position of the buffer in data().
std::vector< T >::iterator iterator
std::size_t capacity() const
Get the capacity.
void append(const_iterator in_begin, const_iterator in_end)
Add new entries to the end.
std::vector< T > _data
The raw data.
void setCapacity(const std::size_t capacity)
Resize the capacity.
T & operator[](const std::size_t index)
Access an entry at index.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
iterator end()
Iterator for the last entry in the buffer.
std::size_t dataEndPos() const
The current end position of the buffer in data().
void move(T &value)
Moves the object into the buffer (calls std::move())
std::size_t _begin_pos
The beginning position.
virtual iterator endChunk(const std::size_t chunk_size)=0
Iterator for the last entry of a chunk size in the buffer If chunk_size is greater than the size of t...
void clear()
Remove all entries (does not change the capacity) Note: this does NOT at all free any entries...
virtual std::size_t newEnd(const std::size_t new_end)=0
Find out where the new end will be.
virtual iterator beginChunk(const std::size_t chunk_size)=0
Iterator for the first entry with a given chunk size in the buffer If chunk_size is greater than the ...
void setSize(const std::size_t size)
Set the size.
iterator begin()
Iterator for the first entry in the buffer.
const std::vector< T > & data()
Access the raw underlying storage.
const_iterator begin() const
Const iterator for the first entry in the buffer.