Commit e958bc53 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Renamed CheckUnusedVector to CheckVector.

parent ff847dce
Pipeline #4582 passed with stages
in 16 minutes and 47 seconds
......@@ -244,7 +244,7 @@ double calc_maxdist_rec2d(size_t i, size_t nlon, double plon, double plat, const
#ifdef USE_YAC
static
size_t find_points_yac(std::vector<char> &vmask, size_t cell_no, size_t ncorner, size_t nadds, std::vector<size_t> &adds, const Varray<double> &xvals1,
size_t find_points_yac(std::vector<char> &vmask, size_t cell_no, size_t ncorner, size_t nadds, Varray<size_t> &adds, const Varray<double> &xvals1,
const Varray<double> &yvals1, const Varray<double> &xbounds, const Varray<double> &ybounds)
{
#ifndef TESTIMPL
......@@ -303,7 +303,7 @@ size_t find_points_yac(std::vector<char> &vmask, size_t cell_no, size_t ncorner,
#endif
static
size_t find_points(std::vector<char> &vmask, size_t cell_no, size_t ncorner, size_t nadds, std::vector<size_t> &adds, const Varray<double> &xvals1,
size_t find_points(std::vector<char> &vmask, size_t cell_no, size_t ncorner, size_t nadds, Varray<size_t> &adds, const Varray<double> &xvals1,
const Varray<double> &yvals1, const Varray<double> &xbounds, const Varray<double> &ybounds)
{
#ifndef TESTIMPL
......@@ -379,7 +379,7 @@ size_t find_points(std::vector<char> &vmask, size_t cell_no, size_t ncorner, siz
}
static
size_t find_points_rec2d(std::vector<char> &vmask, size_t i, size_t nlon2, size_t nadds, std::vector<size_t> &adds, const Varray<double> &xvals1,
size_t find_points_rec2d(std::vector<char> &vmask, size_t i, size_t nlon2, size_t nadds, Varray<size_t> &adds, const Varray<double> &xvals1,
const Varray<double> &yvals1, const Varray<double> &xbounds2d, const Varray<double> &ybounds2d)
{
const auto iy = i / nlon2;
......
......@@ -31,63 +31,60 @@ class
#if defined(__GNUG__)
__attribute__((warn_unused))
#endif
CheckUnusedVector
CheckVector
{
public:
T dummy[1];
T *ptr;
size_t m_count;
CheckUnusedVector() { dummy[0] = 0; }
CheckUnusedVector(size_t count) : m_count(count) { dummy[0] = 0; }
CheckUnusedVector(size_t count, const T& value) : m_count(count) { dummy[0] = value; }
//CheckUnusedVector(CheckUnusedVector&& other) { }
CheckVector() : ptr(dummy) { }
CheckVector(size_t count) : ptr(dummy), m_count(count) { }
CheckVector(size_t count, const T& value) : ptr(dummy), m_count(count) { ptr[0] = value; }
T * begin() noexcept { return &dummy[0]; }
T * end() noexcept { return &dummy[0] + 1; }
T * begin() noexcept { return &ptr[0]; }
T * end() noexcept { return &ptr[0] + 1; }
bool empty() const { return true; }
size_t size() const { return m_count; }
void clear() { }
void shrink_to_fit() { }
void resize(size_t count) { m_count = count; }
void resize(size_t count, const T& value) { m_count = count; dummy[0] = value; }
T * data() noexcept { return &dummy[0]; }
const T* data() const noexcept { return &dummy[0]; }
T& operator[](size_t pos) { (void) pos; return dummy[0]; }
T operator[](size_t pos) const { (void) pos; return dummy[0]; }
//const T& operator [](int pos) { (void) pos; return dummy[0]; }
//const T operator [](int pos) const { (void) pos; return dummy[0]; }
CheckUnusedVector& operator=( const CheckUnusedVector& other ) { (void)other; return *this; }
CheckUnusedVector& operator=( CheckUnusedVector&& other ) { (void)other; return *this; }
// Copy constructor
CheckUnusedVector(const CheckUnusedVector &obj2) { dummy[0] = obj2.dummy[0]; }
};
void resize(size_t count, const T& value) { m_count = count; ptr[0] = value; }
T * data() noexcept { return ptr; }
const T* data() const noexcept { return ptr; }
template <typename T>
using Varray = CheckUnusedVector<T>;
T& operator[](size_t pos) { (void) pos; return ptr[0]; }
const T & operator[](size_t pos) const { (void) pos; return ptr[0]; }
CheckVector& operator=( const CheckVector& other ) { (void)other; return *this; }
CheckVector& operator=( CheckVector&& other ) { (void)other; return *this; }
// Copy constructor
CheckVector(const CheckVector &v2) { ptr[0] = v2.ptr[0]; }
template <typename T>
using Varray2D = Varray<Varray<T>>;
bool operator==(const CheckVector& other) { (void)other; return true; }
template <typename T>
using Varray3D = Varray2D<Varray<T>>;
private:
T dummy[1];
};
template <typename T>
using Varray4D = Varray3D<Varray<T>>;
using Varray = CheckVector<T>;
#else
template <typename T>
using Varray = std::vector<T>;
#endif
template <typename T>
using Varray2D = std::vector<std::vector<T>>;
using Varray2D = Varray<Varray<T>>;
template <typename T>
using Varray3D = std::vector<std::vector<std::vector<T>>>;
using Varray3D = Varray2D<Varray<T>>;
template <typename T>
using Varray4D = std::vector<std::vector<std::vector<std::vector<T>>>>;
#endif
using Varray4D = Varray3D<Varray<T>>;
struct MinMax
......
......@@ -84,7 +84,7 @@ struct RemapGrid
int nvgp; // size of vgpm
std::vector<int> vgpm; // flag which cells are valid
std::vector<int> mask; // flag which cells participate
Varray<int> mask; // flag which cells participate
Varray<double> reg2d_center_lon; // reg2d lon/lat coordinates for
Varray<double> reg2d_center_lat; // each grid center in radians
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment