cnorxz/src/multi_array.h

55 lines
1,008 B
C
Raw Normal View History

2017-02-16 16:06:23 +01:00
2017-02-16 11:20:40 +01:00
// -*- C++ -*-
#ifndef __multi_array_h__
#define __multi_array_h__
#include <cstdlib>
2017-02-16 16:06:23 +01:00
#include <vector>
#include <memory>
2017-02-16 11:20:40 +01:00
#include "base_def.h"
#include "multi_array_operation.h"
2017-02-16 16:06:23 +01:00
#include "name.h"
2017-02-16 11:20:40 +01:00
namespace MultiArrayTools
{
2017-02-16 16:06:23 +01:00
2017-02-16 11:20:40 +01:00
template <typename T, class Range>
class MultiArray
{
public:
DEFAULT_MEMBERS(MultiArray);
2017-02-16 16:06:23 +01:00
MultiArray(const Range& range);
MultiArray(const Range& range, const std::vector<T>& vec);
MultiArray(const Range& range, std::vector<T>&& vec);
2017-02-16 11:20:40 +01:00
template <class... NameTypes>
MultiArrayOperationBase<T,Range> operator()(const NameTypes&... str);
2017-02-16 11:20:40 +01:00
T& operator[](const typename Range::IndexType& i);
const T& operator[](const typename Range::IndexType& i) const;
size_t size() const;
2017-02-23 19:33:46 +01:00
virtual bool isSlice() const;
auto begin() -> decltype(Range().begin());
auto end() -> decltype(Range().end());
2017-02-23 19:33:46 +01:00
protected:
std::shared_ptr<Range> mRange;
2017-02-16 11:20:40 +01:00
private:
bool mInit = false;
2017-02-16 16:06:23 +01:00
std::vector<T> mCont;
2017-02-16 11:20:40 +01:00
};
}
#include "multi_array.cc"
#endif