20#ifndef LIBMESH_STORED_RANGE_H
21#define LIBMESH_STORED_RANGE_H
24#include "libmesh/threads.h"
54template <
typename iterator_type,
typename object_type>
61 typedef typename std::vector<object_type>
vec_type;
91 const iterator_type & last,
100 this->
reset(first, last);
221 middle = beginning + std::distance(beginning, ending)/2u;
228 half = first + (last-first)/2u;
246 const iterator_type & last)
253 for (iterator_type it=first; it!=last; ++it)
254 _objs->push_back(*it);
328 for (
auto it = this->
begin(), it2 = other.
begin();
329 it != this->
end() || it2 != other.
end(); ++it, ++it2)
331 if (it == this->
end() || it2 == other.
end())
363 return objs.size() ? (objs.data()+objs.size()) : objs.data();
The StoredRange class defines a contiguous, divisible set of objects.
static const_iterator end_of(vec_type &objs)
Helper for pre-C++26 compiles, where the compiler may have empty_vector.data() return nullptr and tec...
std::size_t first_idx() const
Index in the stored vector of the first object.
StoredRange(vec_type *objs, const unsigned int new_grainsize=libMesh::default_grainsize())
Constructor.
const object_type * const_iterator
StoredRange(const nonconst_object_type *begin, const nonconst_object_type *end, const unsigned int new_grainsize=libMesh::default_grainsize())
Constructor.
const_iterator begin() const
Beginning of the range.
bool operator==(const StoredRange< iterator_type, object_type > &other) const
std::vector< object_type > vec_type
Allows an StoredRange to behave like an STL container.
const_iterator end() const
End of the range.
StoredRange(const unsigned int new_grainsize=libMesh::default_grainsize())
Constructor.
std::unique_ptr< vec_type, std::function< void(vec_type *)> > ptr_type
StoredRange(StoredRange< iterator_type, object_type > &r, Threads::split)
Splits the range r.
~StoredRange()=default
Destructor.
std::size_t grainsize() const
The grain size for the range.
void grainsize(const unsigned int &gs)
Set the grain size.
bool is_divisible() const
StoredRange< iterator_type, object_type > & reset(const iterator_type &first, const iterator_type &last)
Resets the StoredRange to contain [first,last).
StoredRange< iterator_type, object_type > & reset()
Resets the range to the last specified range.
StoredRange(const iterator_type &first, const iterator_type &last, const unsigned int new_grainsize=libMesh::default_grainsize())
Constructor.
StoredRange(const StoredRange< iterator_type, object_type > &er, const const_iterator &begin_range, const const_iterator &end_range)
NOTE: When using pthreads this constructor is MANDATORY!!!
std::size_t last_idx() const
Index in the stored vector of the last object.
StoredRange(const StoredRange< iterator_type, object_type > &er)
Copy constructor.
std::remove_const_t< std::remove_pointer_t< object_type > > * nonconst_object_type
Allows conversion from non-const to const pointer objects.
Dummy "splitting object" used to distinguish splitting constructors from copy constructors.
The libMesh namespace provides an interface to certain functionality in the library.
unsigned int default_grainsize()
Real distance(const Point &p)