2018-02-14 21:37:18 +01:00
|
|
|
|
|
|
|
#include "ranges/anonymous_range.h"
|
|
|
|
|
|
|
|
namespace MultiArrayTools
|
|
|
|
{
|
|
|
|
/******************************
|
|
|
|
* AnonymousRangeFactory *
|
|
|
|
******************************/
|
|
|
|
|
|
|
|
std::shared_ptr<RangeBase> AnonymousRangeFactory::create()
|
|
|
|
{
|
|
|
|
setSelf();
|
|
|
|
return mProd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************
|
|
|
|
* AnonymousRange *
|
|
|
|
***********************/
|
|
|
|
|
|
|
|
size_t AnonymousRange::get(size_t pos) const
|
|
|
|
{
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t AnonymousRange::getMeta(size_t metaPos) const
|
|
|
|
{
|
|
|
|
return metaPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t AnonymousRange::size() const
|
|
|
|
{
|
|
|
|
return mSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t AnonymousRange::dim() const
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
typename AnonymousRange::IndexType AnonymousRange::begin() const
|
|
|
|
{
|
|
|
|
AnonymousIndex i
|
|
|
|
(std::dynamic_pointer_cast<ClassicRange>
|
|
|
|
( ClassicRange::factory(size()).create() ) ); // !!!
|
|
|
|
i = 0;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
typename AnonymousRange::IndexType AnonymousRange::end() const
|
|
|
|
{
|
|
|
|
AnonymousIndex i
|
|
|
|
( std::dynamic_pointer_cast<ClassicRange>
|
|
|
|
( ClassicRange::factory(size()).create() ));// !!!
|
|
|
|
i = size();
|
|
|
|
return i;
|
|
|
|
}
|
2018-04-28 17:33:57 +02:00
|
|
|
|
|
|
|
std::shared_ptr<RangeBase> AnonymousRange::sub(size_t num) const
|
|
|
|
{
|
|
|
|
return mOrig.at(num);
|
|
|
|
}
|
2018-02-14 21:37:18 +01:00
|
|
|
|
|
|
|
/*****************
|
|
|
|
* Functions *
|
|
|
|
*****************/
|
|
|
|
|
|
|
|
std::shared_ptr<AnonymousRange> defaultRange(size_t size )
|
|
|
|
{
|
|
|
|
AnonymousRangeFactory arf
|
|
|
|
( std::dynamic_pointer_cast<ClassicRange>
|
|
|
|
(ClassicRange::factory(size).create() ) );
|
|
|
|
return std::dynamic_pointer_cast<AnonymousRange>( arf.create() );
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace MultiArrayTools
|