2017-02-16 11:20:40 +01:00
|
|
|
// -*- C++ -*-
|
|
|
|
|
|
|
|
#ifndef __single_range_h__
|
|
|
|
#define __single_range_h__
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <vector>
|
2017-06-01 13:19:27 +02:00
|
|
|
#include <memory>
|
2017-02-16 11:20:40 +01:00
|
|
|
|
2017-12-17 17:40:55 +01:00
|
|
|
//#include "base_def.h"
|
2018-07-16 00:12:05 +02:00
|
|
|
//#include "ranges/rpack_num.h"
|
2017-12-17 17:40:55 +01:00
|
|
|
#include "ranges/index_base.h"
|
|
|
|
#include "ranges/range_base.h"
|
2018-07-21 18:05:53 +02:00
|
|
|
#include "ranges/x_to_string.h"
|
2017-02-16 11:20:40 +01:00
|
|
|
|
2018-01-07 22:33:34 +01:00
|
|
|
#include "xfor/xfor.h"
|
|
|
|
|
|
|
|
using MultiArrayHelper::For;
|
|
|
|
|
2017-02-16 11:20:40 +01:00
|
|
|
namespace MultiArrayTools
|
|
|
|
{
|
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
2017-12-10 18:41:53 +01:00
|
|
|
class SingleIndex : public IndexInterface<SingleIndex<U,TYPE>,U>
|
2017-02-16 11:20:40 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2017-12-11 18:49:43 +01:00
|
|
|
typedef IndexInterface<SingleIndex<U,TYPE>,U> IB;
|
2017-08-04 14:57:19 +02:00
|
|
|
typedef U MetaType;
|
2017-08-11 15:26:10 +02:00
|
|
|
typedef SingleRange<U,TYPE> RangeType;
|
2018-03-05 00:04:50 +01:00
|
|
|
typedef SingleIndex IType;
|
2018-02-13 16:54:13 +01:00
|
|
|
|
2017-08-11 16:45:03 +02:00
|
|
|
//DEFAULT_MEMBERS_X(SingleIndex);
|
2017-08-04 11:27:47 +02:00
|
|
|
|
2017-07-26 18:38:11 +02:00
|
|
|
SingleIndex(const std::shared_ptr<SingleRange<U,TYPE> >& range);
|
2017-08-28 18:28:43 +02:00
|
|
|
|
2018-03-02 16:37:11 +01:00
|
|
|
static constexpr IndexType sType() { return IndexType::SINGLE; }
|
|
|
|
static constexpr size_t totalDim() { return 1; }
|
|
|
|
static constexpr size_t sDim() { return 1; }
|
|
|
|
|
2017-12-11 18:49:43 +01:00
|
|
|
// ==== >>>>> STATIC POLYMORPHISM <<<<< ====
|
|
|
|
|
2017-12-26 15:13:50 +01:00
|
|
|
IndexType type() const;
|
2017-08-11 16:45:03 +02:00
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
SingleIndex& operator=(size_t pos);
|
|
|
|
SingleIndex& operator++();
|
|
|
|
SingleIndex& operator--();
|
2017-12-11 18:49:43 +01:00
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
int pp(std::intptr_t idxPtrNum);
|
|
|
|
int mm(std::intptr_t idxPtrNum);
|
2018-07-22 16:16:24 +02:00
|
|
|
|
|
|
|
std::string stringMeta() const;
|
|
|
|
U meta() const;
|
2018-03-22 11:13:00 +01:00
|
|
|
const U* metaPtr() const;
|
2017-12-17 14:23:23 +01:00
|
|
|
SingleIndex& at(const U& metaPos);
|
2017-03-03 17:51:42 +01:00
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
size_t dim(); // = 1
|
|
|
|
bool last();
|
|
|
|
bool first();
|
2017-08-25 22:03:20 +02:00
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
std::shared_ptr<RangeType> range();
|
2017-12-12 11:15:39 +01:00
|
|
|
|
2017-12-10 18:41:53 +01:00
|
|
|
template <size_t N>
|
2017-12-17 14:23:23 +01:00
|
|
|
void getPtr();
|
2017-12-10 18:41:53 +01:00
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
size_t getStepSize(size_t n);
|
2017-12-10 18:41:53 +01:00
|
|
|
|
2018-01-14 22:41:35 +01:00
|
|
|
std::string id() const;
|
2017-12-17 14:23:23 +01:00
|
|
|
void print(size_t offset);
|
2018-01-07 22:33:34 +01:00
|
|
|
|
2018-01-13 18:07:52 +01:00
|
|
|
template <class Expr>
|
2018-02-12 00:11:24 +01:00
|
|
|
auto ifor(Expr ex) const
|
2018-01-13 18:07:52 +01:00
|
|
|
-> For<SingleIndex<U,TYPE>,Expr>;
|
2018-01-15 14:56:22 +01:00
|
|
|
|
|
|
|
template <class Expr>
|
2018-02-12 00:11:24 +01:00
|
|
|
auto iforh(Expr ex) const
|
2018-01-15 14:56:22 +01:00
|
|
|
-> For<SingleIndex<U,TYPE>,Expr,ForType::HIDDEN>;
|
|
|
|
|
2018-03-19 18:38:53 +01:00
|
|
|
private:
|
2018-03-21 19:18:57 +01:00
|
|
|
const U* mMetaPtr;
|
2017-02-16 11:20:40 +01:00
|
|
|
};
|
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
2017-07-28 11:33:31 +02:00
|
|
|
class SingleRangeFactory : public RangeFactoryBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
typedef SingleRange<U,TYPE> oType;
|
|
|
|
|
|
|
|
SingleRangeFactory() = delete;
|
|
|
|
SingleRangeFactory(const std::vector<U>& space);
|
|
|
|
std::shared_ptr<RangeBase> create();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
2017-08-04 11:27:47 +02:00
|
|
|
class SingleRange : public RangeInterface<SingleIndex<U,TYPE> >
|
2017-02-16 11:20:40 +01:00
|
|
|
{
|
|
|
|
public:
|
2017-08-04 11:27:47 +02:00
|
|
|
typedef RangeBase RB;
|
2017-12-12 11:15:39 +01:00
|
|
|
typedef SingleIndex<U,TYPE> IndexType;
|
2018-03-05 00:04:50 +01:00
|
|
|
typedef SingleRange RangeType;
|
2018-03-21 19:18:57 +01:00
|
|
|
typedef U MetaType;
|
2017-12-12 11:15:39 +01:00
|
|
|
//typedef typename RangeInterface<SingleIndex<U,TYPE> >::IndexType IndexType;
|
2017-02-17 18:10:03 +01:00
|
|
|
|
2017-02-16 16:06:23 +01:00
|
|
|
virtual size_t size() const override;
|
2017-08-04 11:27:47 +02:00
|
|
|
virtual size_t dim() const override;
|
2018-07-21 18:05:53 +02:00
|
|
|
|
|
|
|
virtual std::string stringMeta(size_t pos) const override;
|
|
|
|
virtual std::vector<char> data() const override;
|
2017-08-04 11:27:47 +02:00
|
|
|
|
2017-02-16 11:20:40 +01:00
|
|
|
const U& get(size_t pos) const;
|
2017-03-03 17:51:42 +01:00
|
|
|
size_t getMeta(const U& metaPos) const;
|
2017-02-20 17:18:53 +01:00
|
|
|
|
2017-08-04 14:57:19 +02:00
|
|
|
virtual IndexType begin() const override;
|
|
|
|
virtual IndexType end() const override;
|
2018-02-15 16:24:54 +01:00
|
|
|
|
2017-07-26 18:38:11 +02:00
|
|
|
friend SingleRangeFactory<U,TYPE>;
|
2017-12-15 14:47:02 +01:00
|
|
|
|
2018-02-12 00:11:24 +01:00
|
|
|
static constexpr bool defaultable = false;
|
2018-02-13 16:54:13 +01:00
|
|
|
static constexpr size_t ISSTATIC = 0;
|
|
|
|
static constexpr size_t SIZE = -1;
|
2018-03-19 18:38:53 +01:00
|
|
|
static constexpr bool HASMETACONT = true;
|
2017-02-16 11:20:40 +01:00
|
|
|
|
|
|
|
protected:
|
2017-07-26 18:38:11 +02:00
|
|
|
|
|
|
|
SingleRange() = delete;
|
|
|
|
SingleRange(const SingleRange& in) = delete;
|
2017-06-01 13:19:27 +02:00
|
|
|
|
|
|
|
SingleRange(const std::vector<U>& space);
|
|
|
|
|
2017-02-16 11:20:40 +01:00
|
|
|
std::vector<U> mSpace;
|
|
|
|
};
|
2017-03-14 23:00:41 +01:00
|
|
|
|
2017-11-20 21:35:25 +01:00
|
|
|
}
|
2017-03-30 14:41:57 +02:00
|
|
|
|
2017-11-20 21:35:25 +01:00
|
|
|
/* ========================= *
|
|
|
|
* --- TEMPLATE CODE --- *
|
|
|
|
* ========================= */
|
2017-03-14 23:00:41 +01:00
|
|
|
|
2017-11-20 21:35:25 +01:00
|
|
|
namespace MultiArrayTools
|
|
|
|
{
|
|
|
|
/******************
|
|
|
|
* SingleIndex *
|
|
|
|
******************/
|
|
|
|
|
2018-03-21 16:11:05 +01:00
|
|
|
template <bool HASMETACONT>
|
2018-05-10 14:34:56 +02:00
|
|
|
struct MetaPtrHandle
|
2018-03-21 16:11:05 +01:00
|
|
|
{
|
2018-03-21 19:18:57 +01:00
|
|
|
template <class Range>
|
|
|
|
static const typename Range::MetaType* set(Range* r)
|
2018-03-21 16:11:05 +01:00
|
|
|
{
|
|
|
|
return &r->get(0);
|
|
|
|
}
|
2018-03-21 19:18:57 +01:00
|
|
|
|
2018-05-10 14:34:56 +02:00
|
|
|
template <typename U, class Range>
|
|
|
|
static inline U getMeta(U* metaPtr, size_t pos, std::shared_ptr<Range> r)
|
|
|
|
{
|
|
|
|
return metaPtr[pos];
|
|
|
|
}
|
2018-03-21 16:11:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
2018-05-10 14:34:56 +02:00
|
|
|
struct MetaPtrHandle<false>
|
2018-03-21 16:11:05 +01:00
|
|
|
{
|
2018-03-21 19:18:57 +01:00
|
|
|
template <class Range>
|
|
|
|
static const typename Range::MetaType* set(Range* r)
|
2018-03-21 16:11:05 +01:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
2018-05-10 14:34:56 +02:00
|
|
|
|
|
|
|
template <typename U, class Range>
|
|
|
|
static inline U getMeta(U* metaPtr, size_t pos, std::shared_ptr<Range> r)
|
|
|
|
{
|
|
|
|
return r->get(pos);
|
|
|
|
}
|
2018-03-21 16:11:05 +01:00
|
|
|
};
|
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
2017-11-20 21:35:25 +01:00
|
|
|
SingleIndex<U,TYPE>::SingleIndex(const std::shared_ptr<SingleRange<U,TYPE> >& range) :
|
2018-03-19 18:38:53 +01:00
|
|
|
IndexInterface<SingleIndex<U,TYPE>,U>(range, 0),
|
2018-05-10 14:34:56 +02:00
|
|
|
mMetaPtr(MetaPtrHandle<SingleIndex<U,TYPE>::RangeType::HASMETACONT>::set
|
2018-03-21 19:18:57 +01:00
|
|
|
( dynamic_cast<RangeType*>(IB::mRangePtr.get() ) ) ) {}
|
2017-12-17 14:23:23 +01:00
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
2017-12-26 15:13:50 +01:00
|
|
|
IndexType SingleIndex<U,TYPE>::type() const
|
2017-12-17 14:23:23 +01:00
|
|
|
{
|
|
|
|
return IndexType::SINGLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
SingleIndex<U,TYPE>& SingleIndex<U,TYPE>::operator=(size_t pos)
|
|
|
|
{
|
|
|
|
IB::mPos = pos;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
SingleIndex<U,TYPE>& SingleIndex<U,TYPE>::operator++()
|
|
|
|
{
|
|
|
|
++IB::mPos;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
SingleIndex<U,TYPE>& SingleIndex<U,TYPE>::operator--()
|
|
|
|
{
|
|
|
|
--IB::mPos;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
int SingleIndex<U,TYPE>::pp(std::intptr_t idxPtrNum)
|
|
|
|
{
|
|
|
|
++(*this);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
int SingleIndex<U,TYPE>::mm(std::intptr_t idxPtrNum)
|
|
|
|
{
|
|
|
|
--(*this);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
2018-07-22 16:16:24 +02:00
|
|
|
std::string SingleIndex<U,TYPE>::stringMeta() const
|
|
|
|
{
|
|
|
|
return std::dynamic_pointer_cast<SingleRange<U,TYPE> const>( IB::mRangePtr )->stringMeta(IB::mPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
U SingleIndex<U,TYPE>::meta() const
|
2017-12-17 14:23:23 +01:00
|
|
|
{
|
2018-05-10 14:34:56 +02:00
|
|
|
return MetaPtrHandle<SingleIndex<U,TYPE>::RangeType::HASMETACONT>::getMeta
|
|
|
|
( mMetaPtr, IB::mPos,
|
|
|
|
std::dynamic_pointer_cast<SingleRange<U,TYPE> const>( IB::mRangePtr ) );
|
2017-12-17 14:23:23 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 18:38:53 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
2018-03-22 11:13:00 +01:00
|
|
|
const U* SingleIndex<U,TYPE>::metaPtr() const
|
2018-03-19 18:38:53 +01:00
|
|
|
{
|
|
|
|
return mMetaPtr;
|
|
|
|
}
|
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
SingleIndex<U,TYPE>& SingleIndex<U,TYPE>::at(const U& metaPos)
|
|
|
|
{
|
|
|
|
(*this) = std::dynamic_pointer_cast<SingleRange<U,TYPE> const>( IB::mRangePtr )->getMeta( metaPos );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
size_t SingleIndex<U,TYPE>::dim() // = 1
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
bool SingleIndex<U,TYPE>::last()
|
|
|
|
{
|
|
|
|
return IB::mPos == IB::mMax - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
bool SingleIndex<U,TYPE>::first()
|
|
|
|
{
|
|
|
|
return IB::mPos == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
std::shared_ptr<typename SingleIndex<U,TYPE>::RangeType> SingleIndex<U,TYPE>::range()
|
|
|
|
{
|
|
|
|
return std::dynamic_pointer_cast<RangeType>( IB::mRangePtr );
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
template <size_t N>
|
|
|
|
void SingleIndex<U,TYPE>::getPtr() {}
|
2017-12-24 18:14:07 +01:00
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
size_t SingleIndex<U,TYPE>::getStepSize(size_t n)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
2018-01-14 22:41:35 +01:00
|
|
|
std::string SingleIndex<U,TYPE>::id() const
|
2017-12-17 14:23:23 +01:00
|
|
|
{
|
|
|
|
return std::string("sin") + std::to_string(IB::mId);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
void SingleIndex<U,TYPE>::print(size_t offset)
|
|
|
|
{
|
|
|
|
if(offset == 0){
|
|
|
|
std::cout << " === " << std::endl;
|
|
|
|
}
|
|
|
|
for(size_t j = 0; j != offset; ++j) { std::cout << "\t"; }
|
|
|
|
std::cout << id() << "[" << reinterpret_cast<std::intptr_t>(this)
|
|
|
|
<< "](" << IB::mRangePtr << "): " << meta() << std::endl;
|
|
|
|
}
|
|
|
|
|
2018-01-07 22:33:34 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
2018-01-13 18:07:52 +01:00
|
|
|
template <class Expr>
|
2018-02-12 00:11:24 +01:00
|
|
|
auto SingleIndex<U,TYPE>::ifor(Expr ex) const
|
2018-01-13 18:07:52 +01:00
|
|
|
-> For<SingleIndex<U,TYPE>,Expr>
|
2018-01-07 22:33:34 +01:00
|
|
|
{
|
2018-01-13 18:07:52 +01:00
|
|
|
//static const size_t LAYER = typename Expr::LAYER;
|
2018-02-12 00:11:24 +01:00
|
|
|
return For<SingleIndex<U,TYPE>,Expr>(this, ex);
|
2018-01-07 22:33:34 +01:00
|
|
|
}
|
|
|
|
|
2018-01-15 14:56:22 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
template <class Expr>
|
2018-02-12 00:11:24 +01:00
|
|
|
auto SingleIndex<U,TYPE>::iforh(Expr ex) const
|
2018-01-15 14:56:22 +01:00
|
|
|
-> For<SingleIndex<U,TYPE>,Expr,ForType::HIDDEN>
|
|
|
|
{
|
|
|
|
//static const size_t LAYER = typename Expr::LAYER;
|
2018-02-12 00:11:24 +01:00
|
|
|
return For<SingleIndex<U,TYPE>,Expr,ForType::HIDDEN>(this, ex);
|
2018-01-15 14:56:22 +01:00
|
|
|
}
|
|
|
|
|
2017-11-20 21:35:25 +01:00
|
|
|
|
|
|
|
/********************
|
|
|
|
* SingleRange *
|
|
|
|
********************/
|
2017-03-14 23:00:41 +01:00
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
2017-11-20 21:35:25 +01:00
|
|
|
SingleRangeFactory<U,TYPE>::SingleRangeFactory(const std::vector<U>& space)
|
2017-03-14 23:00:41 +01:00
|
|
|
{
|
2017-11-20 21:35:25 +01:00
|
|
|
mProd = std::shared_ptr<oType>( new SingleRange<U,TYPE>( space ) );
|
|
|
|
}
|
2017-03-14 23:00:41 +01:00
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
2017-11-20 21:35:25 +01:00
|
|
|
std::shared_ptr<RangeBase> SingleRangeFactory<U,TYPE>::create()
|
|
|
|
{
|
|
|
|
setSelf();
|
|
|
|
return mProd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************
|
|
|
|
* SingleRange *
|
|
|
|
********************/
|
2017-03-15 22:54:48 +01:00
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
2017-11-20 21:35:25 +01:00
|
|
|
SingleRange<U,TYPE>::SingleRange(const std::vector<U>& space) : RangeInterface<SingleIndex<U,TYPE> >(),
|
|
|
|
mSpace(space) {}
|
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
2017-11-20 21:35:25 +01:00
|
|
|
const U& SingleRange<U,TYPE>::get(size_t pos) const
|
2017-03-14 23:00:41 +01:00
|
|
|
{
|
2017-11-20 21:35:25 +01:00
|
|
|
return mSpace[pos];
|
|
|
|
}
|
2017-03-14 23:00:41 +01:00
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
2017-11-20 21:35:25 +01:00
|
|
|
size_t SingleRange<U,TYPE>::getMeta(const U& metaPos) const
|
|
|
|
{
|
|
|
|
size_t cnt = 0;
|
|
|
|
for(auto& x: mSpace){
|
|
|
|
if(x == metaPos){
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
++cnt;
|
|
|
|
}
|
|
|
|
return cnt;
|
|
|
|
}
|
2017-03-14 23:00:41 +01:00
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
2017-11-20 21:35:25 +01:00
|
|
|
size_t SingleRange<U,TYPE>::size() const
|
|
|
|
{
|
|
|
|
return mSpace.size();
|
|
|
|
}
|
2017-03-14 23:00:41 +01:00
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
2017-11-20 21:35:25 +01:00
|
|
|
size_t SingleRange<U,TYPE>::dim() const
|
2017-03-14 23:00:41 +01:00
|
|
|
{
|
2017-11-20 21:35:25 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2017-03-14 23:00:41 +01:00
|
|
|
|
2018-07-21 18:05:53 +02:00
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
std::string SingleRange<U,TYPE>::stringMeta(size_t pos) const
|
|
|
|
{
|
|
|
|
return xToString(get(pos));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U, SpaceType TYPE>
|
|
|
|
std::vector<char> SingleRange<U,TYPE>::data() const
|
|
|
|
{
|
|
|
|
DataHeader h;
|
|
|
|
h.spaceType = static_cast<int>( TYPE );
|
|
|
|
h.metaSize = size() * sizeof(U);
|
|
|
|
h.multiple = 0;
|
|
|
|
std::vector<char> out;
|
|
|
|
out.reserve(h.metaSize + sizeof(DataHeader));
|
|
|
|
char* hcp = reinterpret_cast<char*>(&h);
|
|
|
|
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
2018-07-22 18:32:43 +02:00
|
|
|
stringCat(out, mSpace);
|
|
|
|
//const char* scp = reinterpret_cast<const char*>(mSpace.data());
|
|
|
|
//out.insert(out.end(), scp, scp + h.metaSize);
|
2018-07-21 18:05:53 +02:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
2017-11-20 21:35:25 +01:00
|
|
|
typename SingleRange<U,TYPE>::IndexType SingleRange<U,TYPE>::begin() const
|
|
|
|
{
|
|
|
|
SingleIndex<U,TYPE> i( std::dynamic_pointer_cast<SingleRange<U,TYPE> >
|
|
|
|
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
|
|
|
i = 0;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2017-12-17 14:23:23 +01:00
|
|
|
template <typename U, SpaceType TYPE>
|
2017-11-20 21:35:25 +01:00
|
|
|
typename SingleRange<U,TYPE>::IndexType SingleRange<U,TYPE>::end() const
|
|
|
|
{
|
|
|
|
SingleIndex<U,TYPE> i( std::dynamic_pointer_cast<SingleRange<U,TYPE> >
|
|
|
|
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
|
|
|
i = size();
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
2017-02-16 11:20:40 +01:00
|
|
|
|
2017-12-04 18:29:18 +01:00
|
|
|
#include "range_types/header.h"
|
|
|
|
|
2017-02-16 11:20:40 +01:00
|
|
|
#endif
|