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 */
|
/** default destructor */
|
||||||
virtual ~CArrayBase() = default;
|
virtual ~CArrayBase() = default;
|
||||||
|
|
||||||
|
/** Return unique pointer copy of itself. */
|
||||||
|
virtual Uptr<CArrayBase> copy() const = 0;
|
||||||
|
|
||||||
/** const data element access.
|
/** const data element access.
|
||||||
If the array's format is trivial or the index is already non-trivially formatted,
|
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.
|
this is equivalent to data()[i.pos()]. Otherwise, the array's format is applied.
|
||||||
|
|
|
@ -61,6 +61,12 @@ namespace CNORXZ
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
Uptr<CArrayBase<T>> MArray<T>::copy() const
|
||||||
|
{
|
||||||
|
return std::make_unique<MArray<T>>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T* MArray<T>::data() const
|
const T* MArray<T>::data() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace CNORXZ
|
||||||
MArray& init(const RangePtr& range);
|
MArray& init(const RangePtr& range);
|
||||||
MArray& extend(const RangePtr& range);
|
MArray& extend(const RangePtr& range);
|
||||||
|
|
||||||
|
virtual Uptr<CArrayBase<T>> copy() const override;
|
||||||
virtual const T* data() const override;
|
virtual const T* data() const override;
|
||||||
virtual T* data() override;
|
virtual T* data() override;
|
||||||
virtual const_iterator cbegin() const override;
|
virtual const_iterator cbegin() const override;
|
||||||
|
|
|
@ -29,6 +29,12 @@ namespace CNORXZ
|
||||||
mOff(off)
|
mOff(off)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
Uptr<CArrayBase<T>> CSlice<T>::copy() const
|
||||||
|
{
|
||||||
|
return std::make_unique<CSlice<T>>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T* CSlice<T>::data() const
|
const T* CSlice<T>::data() const
|
||||||
{
|
{
|
||||||
|
@ -76,6 +82,12 @@ namespace CNORXZ
|
||||||
mOff(off)
|
mOff(off)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
Uptr<CArrayBase<T>> Slice<T>::copy() const
|
||||||
|
{
|
||||||
|
return std::make_unique<Slice<T>>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T* Slice<T>::data()
|
T* Slice<T>::data()
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,7 +41,8 @@ namespace CNORXZ
|
||||||
*/
|
*/
|
||||||
CSlice(const RangePtr& range, const CArrayBase<T>* parent,
|
CSlice(const RangePtr& range, const CArrayBase<T>* parent,
|
||||||
const YFormat& blockSizes, SizeT off);
|
const YFormat& blockSizes, SizeT off);
|
||||||
|
|
||||||
|
virtual Uptr<CArrayBase<T>> copy() const override;
|
||||||
virtual const T* data() const override;
|
virtual const T* data() const override;
|
||||||
virtual const_iterator cbegin() const override;
|
virtual const_iterator cbegin() const override;
|
||||||
virtual const_iterator cend() const override;
|
virtual const_iterator cend() const override;
|
||||||
|
@ -82,6 +83,7 @@ namespace CNORXZ
|
||||||
Slice(const RangePtr& range, ArrayBase<T>* parent,
|
Slice(const RangePtr& range, ArrayBase<T>* parent,
|
||||||
const YFormat& blockSizes, SizeT off);
|
const YFormat& blockSizes, SizeT off);
|
||||||
|
|
||||||
|
virtual Uptr<CArrayBase<T>> copy() const override;
|
||||||
virtual const T* data() const override;
|
virtual const T* data() const override;
|
||||||
virtual T* data() override;
|
virtual T* data() override;
|
||||||
virtual const_iterator cbegin() const override;
|
virtual const_iterator cbegin() const override;
|
||||||
|
|
|
@ -152,13 +152,13 @@ namespace CNORXZ
|
||||||
template <class I>
|
template <class I>
|
||||||
struct is_rank_index
|
struct is_rank_index
|
||||||
{
|
{
|
||||||
constexpr bool value = false;
|
static constexpr bool value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class IndexI, class IndexK>
|
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