array objects: copy function
This commit is contained in:
parent
bd2af23b15
commit
c43698dc10
6 changed files with 28 additions and 4 deletions
|
@ -45,6 +45,9 @@ namespace CNORXZ
|
|||
/** default destructor */
|
||||
virtual ~CArrayBase() = default;
|
||||
|
||||
/** Return unique pointer copy of itself. */
|
||||
virtual Uptr<CArrayBase> copy() const = 0;
|
||||
|
||||
/** const data element access.
|
||||
If the array's format is trivial or the index is already non-trivially formatted,
|
||||
this is equivalent to data()[i.pos()]. Otherwise, the array's format is applied.
|
||||
|
|
|
@ -61,6 +61,12 @@ namespace CNORXZ
|
|||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Uptr<CArrayBase<T>> MArray<T>::copy() const
|
||||
{
|
||||
return std::make_unique<MArray<T>>(*this);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T* MArray<T>::data() const
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace CNORXZ
|
|||
MArray& init(const RangePtr& range);
|
||||
MArray& extend(const RangePtr& range);
|
||||
|
||||
virtual Uptr<CArrayBase<T>> copy() const override;
|
||||
virtual const T* data() const override;
|
||||
virtual T* data() override;
|
||||
virtual const_iterator cbegin() const override;
|
||||
|
|
|
@ -29,6 +29,12 @@ namespace CNORXZ
|
|||
mOff(off)
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
Uptr<CArrayBase<T>> CSlice<T>::copy() const
|
||||
{
|
||||
return std::make_unique<CSlice<T>>(*this);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T* CSlice<T>::data() const
|
||||
{
|
||||
|
@ -76,6 +82,12 @@ namespace CNORXZ
|
|||
mOff(off)
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
Uptr<CArrayBase<T>> Slice<T>::copy() const
|
||||
{
|
||||
return std::make_unique<Slice<T>>(*this);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* Slice<T>::data()
|
||||
{
|
||||
|
|
|
@ -41,7 +41,8 @@ namespace CNORXZ
|
|||
*/
|
||||
CSlice(const RangePtr& range, const CArrayBase<T>* parent,
|
||||
const YFormat& blockSizes, SizeT off);
|
||||
|
||||
|
||||
virtual Uptr<CArrayBase<T>> copy() const override;
|
||||
virtual const T* data() const override;
|
||||
virtual const_iterator cbegin() const override;
|
||||
virtual const_iterator cend() const override;
|
||||
|
@ -82,6 +83,7 @@ namespace CNORXZ
|
|||
Slice(const RangePtr& range, ArrayBase<T>* parent,
|
||||
const YFormat& blockSizes, SizeT off);
|
||||
|
||||
virtual Uptr<CArrayBase<T>> copy() const override;
|
||||
virtual const T* data() const override;
|
||||
virtual T* data() override;
|
||||
virtual const_iterator cbegin() const override;
|
||||
|
|
|
@ -152,13 +152,13 @@ namespace CNORXZ
|
|||
template <class I>
|
||||
struct is_rank_index
|
||||
{
|
||||
constexpr bool value = false;
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template <class IndexI, class IndexK>
|
||||
struct is_rank_index<IndexI,IndexK>
|
||||
struct is_rank_index<RIndex<IndexI,IndexK>>
|
||||
{
|
||||
constexpr bool value = true;
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
/** ****
|
||||
|
|
Loading…
Reference in a new issue