2017-03-08 22:53:18 +01:00
|
|
|
// -*- C++ -*-
|
2017-02-16 13:12:20 +01:00
|
|
|
#include "index_base.h"
|
|
|
|
|
|
|
|
namespace MultiArrayTools
|
|
|
|
{
|
2017-07-25 17:46:59 +02:00
|
|
|
/*****************
|
|
|
|
* IndexBase *
|
|
|
|
*****************/
|
2017-05-24 19:01:02 +02:00
|
|
|
|
2017-07-25 17:46:59 +02:00
|
|
|
IndexBase::IndexBase(const std::shared_ptr<RangeBase>& range,
|
|
|
|
size_t pos) : mRangePtr(range),
|
|
|
|
mPos(pos) {}
|
2017-05-22 18:21:14 +02:00
|
|
|
|
2017-07-25 17:46:59 +02:00
|
|
|
bool IndexBase::operator==(const IndexBase& in) const
|
2017-05-22 18:21:14 +02:00
|
|
|
{
|
2017-07-25 17:46:59 +02:00
|
|
|
return in.mPos == mPos and in.mRangePtr.get() == mRangePtr.get();
|
2017-03-13 19:04:24 +01:00
|
|
|
}
|
|
|
|
|
2017-07-25 17:46:59 +02:00
|
|
|
bool IndexBase::operator!=(const IndexBase& in) const
|
2017-03-13 19:04:24 +01:00
|
|
|
{
|
2017-07-25 17:46:59 +02:00
|
|
|
return in.mPos != mPos or in.mRangePtr.get() != mRangePtr.get();
|
2017-05-22 18:21:14 +02:00
|
|
|
}
|
|
|
|
|
2017-07-25 17:46:59 +02:00
|
|
|
size_t IndexBase::pos() const
|
2017-02-21 17:41:48 +01:00
|
|
|
{
|
2017-07-25 17:46:59 +02:00
|
|
|
return mPos;
|
2017-02-21 17:41:48 +01:00
|
|
|
}
|
2017-02-22 13:34:32 +01:00
|
|
|
|
2017-07-26 18:38:11 +02:00
|
|
|
size_t IndexBase::max() const
|
|
|
|
{
|
|
|
|
return mRangePtr->size();
|
|
|
|
}
|
|
|
|
|
2017-08-04 11:27:47 +02:00
|
|
|
IndexBase::operator size_t() const
|
2017-03-13 16:24:00 +01:00
|
|
|
{
|
2017-07-27 14:48:41 +02:00
|
|
|
return pos();
|
2017-02-22 13:34:32 +01:00
|
|
|
}
|
2017-02-16 13:12:20 +01:00
|
|
|
|
2017-07-25 17:46:59 +02:00
|
|
|
/**********************
|
|
|
|
* IndexInterface *
|
|
|
|
**********************/
|
2017-02-16 13:12:20 +01:00
|
|
|
|
2017-07-25 17:46:59 +02:00
|
|
|
template <typename MetaType>
|
2017-08-04 14:57:19 +02:00
|
|
|
IndexInterface<MetaType>::IndexInterface(const std::shared_ptr<RangeBase>& rangePtr, size_t pos) :
|
|
|
|
IndexBase(rangePtr, pos) {}
|
2017-02-21 17:41:48 +01:00
|
|
|
|
2017-02-16 13:12:20 +01:00
|
|
|
}
|