cnorxz/src/include/array/darray_base.h

97 lines
2.1 KiB
C
Raw Normal View History

2022-08-31 14:58:39 +02:00
#ifndef __cxz_darray_base_h__
#define __cxz_darray_base_h__
#include <cstdlib>
#include <vector>
#include <memory>
#include <algorithm>
2022-09-15 16:45:45 +02:00
#include "base/base.h"
2022-09-17 22:08:01 +02:00
#include "aindex.h"
2022-09-15 16:45:45 +02:00
//#include "operation/"
2022-08-31 14:58:39 +02:00
namespace CNORXZ
{
template <typename T>
class DArrayBase
{
public:
2022-09-17 22:08:01 +02:00
typedef AIndex<T> const_iterator;
2022-08-31 14:58:39 +02:00
protected:
RangePtr mRange;
public:
DArrayBase(const RangePtr& range);
DEFAULT_MEMBERS(DArrayBase);
virtual ~DArrayBase() = default;
template <typename I, typename M>
const T& operator[](const IndexInterface<I,M>& i) const;
2022-08-31 14:58:39 +02:00
template <typename I, typename M>
const T& at(const IndexInterface<I,M>& i) const;
2022-08-31 14:58:39 +02:00
template <typename I, typename M>
2022-09-17 22:08:01 +02:00
Sptr<DArrayBase<T>> sl(const IndexInterface<I,M>& i) const;
2022-08-31 14:58:39 +02:00
virtual const T* data() const = 0;
virtual SizeT pmax() const = 0; // max allocated postion of data() (exclusive!)
2022-09-17 22:08:01 +02:00
virtual SizeT size() const;
2022-08-31 14:58:39 +02:00
virtual RangePtr range() const;
virtual const_iterator begin() const;
virtual const_iterator end() const;
virtual const_iterator cbegin() const = 0;
virtual const_iterator cend() const = 0;
virtual bool isView() const = 0;
2022-09-15 16:45:45 +02:00
//template <typename I, typename M>
//ConstOperationRoot<T,I> operator()(const IndexPtr<I,M>& i) const;
2022-08-31 14:58:39 +02:00
};
template <typename T>
class MDArrayBase : public DArrayBase<T>
{
public:
typedef DArrayBase<T> DAB;
typedef typename DAB::const_iterator const_iterator;
2022-09-17 22:08:01 +02:00
typedef BIndex<T> iterator;
2022-08-31 14:58:39 +02:00
using DAB::operator[];
using DAB::at;
using DAB::data;
using DAB::begin;
using DAB::end;
using DAB::cbegin;
using DAB::cend;
2022-09-15 16:45:45 +02:00
//using DAB::operator();
2022-08-31 14:58:39 +02:00
MDArrayBase(const RangePtr& range);
DEFAULT_MEMBERS(MDArrayBase);
template <typename I, typename M>
T& operator[](const IndexInterface<I,M>& i);
2022-08-31 14:58:39 +02:00
template <typename I, typename M>
T& at(const IndexInterface<I,M>& i);
2022-08-31 14:58:39 +02:00
template <typename I, typename M>
2022-09-17 22:08:01 +02:00
Sptr<MDArrayBase<T>> sl(const IndexInterface<I,M>& i);
2022-08-31 14:58:39 +02:00
virtual T* data() = 0;
virtual iterator begin();
virtual iterator end();
2022-09-15 16:45:45 +02:00
//template <typename I, typename M>
//OperationRoot<T,I> operator()(const IndexPtr<I,M>& i);
2022-08-31 14:58:39 +02:00
};
}
#endif