3#include <AMReX_Config.H>
24template <
class T,
class Allocator=std::allocator<T> >
27 public std::vector<T, Allocator>
31 using std::vector<T, Allocator>::vector;
32 using typename std::vector<T, Allocator>::size_type;
37 "Out of bound error, index: " + std::to_string(i) +
" size: " + std::to_string(
size()));
38 return this->std::vector<T, Allocator>::operator[](i);
41 [[nodiscard]]
const T&
operator[] (size_type i)
const noexcept
44 "Out of bound error, index: " + std::to_string(i) +
" size: " + std::to_string(
size()));
45 return this->std::vector<T, Allocator>::operator[](i);
49 [[nodiscard]] T*
dataPtr () noexcept {
return this->data(); }
51 [[nodiscard]]
const T*
dataPtr () const noexcept {
return this->data(); }
53 [[nodiscard]]
Long size () const noexcept {
return static_cast<Long>(std::vector<T, Allocator>::size());}
63 template <
class T,
typename =
typename T::FABType>
68 for (
auto&
x : a) {
r.push_back(&
x); }
72 template <
class T, std::
size_t N,
typename =
typename T::FABType>
77 for (
auto&
x : a) {
r.push_back(&
x); }
86 for (
const auto&
x : a) {
r.push_back(
x.get()); }
92 template <
class T,
typename =
typename T::FABType>
97 for (
const auto&
x : a) {
r.push_back(&
x); }
101 template <
class T, std::
size_t N,
typename =
typename T::FABType>
106 for (
auto&
x : a) {
r.push_back(&
x); }
115 for (
const auto&
x : a) {
r.push_back(
x.get()); }
119 template <
class T,
typename =
typename T::FABType>
122 return {a.begin(), a.end()};
140 [[nodiscard]] Vector<std::array<T*,AMREX_SPACEDIM> >
150 [[nodiscard]] Vector<std::array<T const*,AMREX_SPACEDIM> >
160 [[nodiscard]] Vector<std::array<T const*,AMREX_SPACEDIM> >
169 template <class T, std::enable_if_t<IsFabArray<T>::value ||
172 [[nodiscard]] Vector<std::array<T const*,AMREX_SPACEDIM> >
181 template <class T, std::enable_if_t<IsFabArray<T>::value ||
184 [[nodiscard]] Vector<std::array<T*, AMREX_SPACEDIM> >
199 std::for_each(a.begin(), a.end(), [](T*& p) { p = nullptr; });
205 std::for_each(a.begin(), a.end(), [](std::unique_ptr<T>& p) { p.reset(); });
212 std::sort(vec.begin(), vec.end());
213 auto it = std::unique(vec.begin(), vec.end());
214 vec.erase(it, vec.end());
218 template <
class T,
class H>
221 std::size_t N = stop-start;
222 if (N < 2) {
return stop; }
224 T*
const data = vec.data() + start;
225 T
const sentinel = data[0];
227 for (std::size_t i = 1; i < N; ) {
228 if (data[i] == sentinel) {
233 std::size_t
const hash = hasher(data[i]) % N;
239 if (data[i] == data[hash]) {
245 if (data[hash] == sentinel) {
246 std::swap(data[hash], data[i]);
253 std::size_t
const hashhash = hasher(data[hash]) % N;
254 if (hashhash != hash) {
255 std::swap(data[i], data[hash]);
275 std::size_t swapPos = 0;
276 for (std::size_t i = 0; i < N; ++i) {
278 if (data[i] != sentinel && i == hasher(data[i]) % N) {
279 std::swap(data[i], data[swapPos++]);
285 std::size_t sentinelPos = N;
286 for (std::size_t i = swapPos; i < sentinelPos; ) {
288 if(data[i] == sentinel) {
289 std::swap(data[i], data[--sentinelPos]);
296 return detail::removeDupDoit<T,H>(vec, start+swapPos, start+sentinelPos+1);
300 template <
class T,
class H>
303 std::size_t pos = detail::removeDupDoit<T,H>(vec, 0, vec.
size());
304 vec.erase(vec.begin()+pos, vec.end());
#define AMREX_ASSERT_WITH_MESSAGE(EX, MSG)
Definition AMReX_BLassert.H:37
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:28
T & operator[](size_type i) noexcept
Definition AMReX_Vector.H:34
T * dataPtr() noexcept
get access to the underlying data pointer
Definition AMReX_Vector.H:49
Long size() const noexcept
Definition AMReX_Vector.H:53
const T * dataPtr() const noexcept
get access to the underlying data pointer
Definition AMReX_Vector.H:51
amrex_long Long
Definition AMReX_INT.H:30
std::array< T, N > Array
Definition AMReX_Array.H:25
std::size_t removeDupDoit(Vector< T > &vec, std::size_t start, std::size_t stop)
Definition AMReX_Vector.H:219
Definition AMReX_Amr.cpp:49
std::array< T const *, 3 > GetArrOfConstPtrs(const std::array< T, 3 > &a) noexcept
Definition AMReX_Array.H:1016
Vector< std::array< T const *, 3 > > GetVecOfArrOfPtrsConst(const Vector< std::array< std::unique_ptr< T >, 3 > > &a)
Definition AMReX_Vector.H:151
Vector< const T * > GetVecOfConstPtrs(const Vector< T > &a)
Definition AMReX_Vector.H:93
std::array< T *, 3 > GetArrOfPtrs(std::array< T, 3 > &a) noexcept
Definition AMReX_Array.H:1004
Vector< T * > GetVecOfPtrs(Vector< T > &a)
Definition AMReX_Vector.H:64
void FillNull(Vector< T * > &a)
Definition AMReX_Vector.H:197
Vector< Vector< T * > > GetVecOfVecOfPtrs(const Vector< Vector< std::unique_ptr< T > > > &a)
Definition AMReX_Vector.H:128
Vector< std::array< T const *, 3 > > GetVecOfArrOfConstPtrs(const Vector< std::array< std::unique_ptr< T >, 3 > > &a)
Definition AMReX_Vector.H:161
Vector< std::array< T *, 3 > > GetVecOfArrOfPtrs(const Vector< std::array< std::unique_ptr< T >, 3 > > &a)
Definition AMReX_Vector.H:141
void RemoveDuplicates(Vector< T > &vec)
Definition AMReX_Vector.H:211
Definition AMReX_FabArrayCommI.H:1011