3#include <AMReX_Config.H>
23template <
class T,
class Allocator=std::allocator<T> >
26 public std::vector<T, Allocator>
30 using std::vector<T, Allocator>::vector;
31 using typename std::vector<T, Allocator>::size_type;
35 BL_ASSERT( i < (this->std::vector<T, Allocator>::size()) );
36 return this->std::vector<T, Allocator>::operator[](i);
39 [[nodiscard]]
const T&
operator[] (size_type i)
const noexcept
41 BL_ASSERT( i < (this->std::vector<T, Allocator>::size()) );
42 return this->std::vector<T, Allocator>::operator[](i);
46 [[nodiscard]] T*
dataPtr () noexcept {
return this->data(); }
48 [[nodiscard]]
const T*
dataPtr () const noexcept {
return this->data(); }
50 [[nodiscard]] Long
size () const noexcept {
return static_cast<Long
>(std::vector<T, Allocator>::size());}
60 template <
class T,
typename =
typename T::FABType>
65 for (
auto&
x : a) {
r.push_back(&
x); }
69 template <
class T, std::
size_t N,
typename =
typename T::FABType>
74 for (
auto&
x : a) {
r.push_back(&
x); }
83 for (
const auto&
x : a) {
r.push_back(
x.get()); }
89 template <
class T,
typename =
typename T::FABType>
94 for (
const auto&
x : a) {
r.push_back(&
x); }
98 template <
class T, std::
size_t N,
typename =
typename T::FABType>
103 for (
auto&
x : a) {
r.push_back(&
x); }
112 for (
const auto&
x : a) {
r.push_back(
x.get()); }
116 template <
class T,
typename =
typename T::FABType>
119 return {a.begin(), a.end()};
137 [[nodiscard]] Vector<std::array<T*,AMREX_SPACEDIM> >
147 [[nodiscard]] Vector<std::array<T const*,AMREX_SPACEDIM> >
157 [[nodiscard]] Vector<std::array<T const*,AMREX_SPACEDIM> >
166 template <class T, std::enable_if_t<IsFabArray<T>::value ||
169 [[nodiscard]] Vector<std::array<T const*,AMREX_SPACEDIM> >
178 template <class T, std::enable_if_t<IsFabArray<T>::value ||
181 [[nodiscard]] Vector<std::array<T*, AMREX_SPACEDIM> >
196 std::for_each(a.begin(), a.end(), [](T*& p) { p = nullptr; });
202 std::for_each(a.begin(), a.end(), [](std::unique_ptr<T>& p) { p.reset(); });
209 std::sort(vec.begin(), vec.end());
210 auto it = std::unique(vec.begin(), vec.end());
211 vec.erase(it, vec.end());
215 template <
class T,
class H>
218 std::size_t N = stop-start;
219 if (N < 2) {
return stop; }
221 T*
const data = vec.data() + start;
222 T
const sentinel = data[0];
224 for (std::size_t i = 1; i < N; ) {
225 if (data[i] == sentinel) {
230 std::size_t
const hash = hasher(data[i]) % N;
236 if (data[i] == data[hash]) {
242 if (data[hash] == sentinel) {
243 std::swap(data[hash], data[i]);
250 std::size_t
const hashhash = hasher(data[hash]) % N;
251 if (hashhash != hash) {
252 std::swap(data[i], data[hash]);
272 std::size_t swapPos = 0;
273 for (std::size_t i = 0; i < N; ++i) {
275 if (data[i] != sentinel && i == hasher(data[i]) % N) {
276 std::swap(data[i], data[swapPos++]);
282 std::size_t sentinelPos = N;
283 for (std::size_t i = swapPos; i < sentinelPos; ) {
285 if(data[i] == sentinel) {
286 std::swap(data[i], data[--sentinelPos]);
293 return detail::removeDupDoit<T,H>(vec, start+swapPos, start+sentinelPos+1);
297 template <
class T,
class H>
300 std::size_t pos = detail::removeDupDoit<T,H>(vec, 0, vec.
size());
301 vec.erase(vec.begin()+pos, vec.end());
#define BL_ASSERT(EX)
Definition AMReX_BLassert.H:39
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:27
T & operator[](size_type i) noexcept
Definition AMReX_Vector.H:33
T * dataPtr() noexcept
get access to the underlying data pointer
Definition AMReX_Vector.H:46
Long size() const noexcept
Definition AMReX_Vector.H:50
const T * dataPtr() const noexcept
get access to the underlying data pointer
Definition AMReX_Vector.H:48
std::size_t removeDupDoit(Vector< T > &vec, std::size_t start, std::size_t stop)
Definition AMReX_Vector.H:216
Definition AMReX_Amr.cpp:49
Vector< std::array< T const *, AMREX_SPACEDIM > > GetVecOfArrOfConstPtrs(const Vector< std::array< std::unique_ptr< T >, AMREX_SPACEDIM > > &a)
Definition AMReX_Vector.H:158
Vector< const T * > GetVecOfConstPtrs(const Vector< T > &a)
Definition AMReX_Vector.H:90
Vector< std::array< T *, AMREX_SPACEDIM > > GetVecOfArrOfPtrs(const Vector< std::array< std::unique_ptr< T >, AMREX_SPACEDIM > > &a)
Definition AMReX_Vector.H:138
Vector< T * > GetVecOfPtrs(Vector< T > &a)
Definition AMReX_Vector.H:61
std::array< T *, AMREX_SPACEDIM > GetArrOfPtrs(std::array< T, AMREX_SPACEDIM > &a) noexcept
Definition AMReX_Array.H:966
void FillNull(Vector< T * > &a)
Definition AMReX_Vector.H:194
Vector< Vector< T * > > GetVecOfVecOfPtrs(const Vector< Vector< std::unique_ptr< T > > > &a)
Definition AMReX_Vector.H:125
std::array< T const *, AMREX_SPACEDIM > GetArrOfConstPtrs(const std::array< T, AMREX_SPACEDIM > &a) noexcept
Definition AMReX_Array.H:978
Vector< std::array< T const *, AMREX_SPACEDIM > > GetVecOfArrOfPtrsConst(const Vector< std::array< std::unique_ptr< T >, AMREX_SPACEDIM > > &a)
Definition AMReX_Vector.H:148
void RemoveDuplicates(Vector< T > &vec)
Definition AMReX_Vector.H:208
std::array< T, N > Array
Definition AMReX_Array.H:24
Definition AMReX_FabArrayCommI.H:896