Skip to content
Snippets Groups Projects
Commit 675c6d7f authored by Tobias Leibner's avatar Tobias Leibner
Browse files

[container.vector-interface-internal] clean up iterator

parent c03d7614
No related branches found
No related tags found
No related merge requests found
......@@ -490,7 +490,7 @@ template <class T>
struct VectorAbstraction<LA::CommonSparseVector<T>>
: public LA::internal::VectorAbstractionBase<LA::CommonSparseVector<T>>
{
static const bool contiguous = false;
static const bool is_contiguous = false;
};
......
......@@ -38,26 +38,16 @@ public:
typedef VectorInterface<Traits, ScalarImp> VectorType;
typedef typename VectorType::ScalarType ScalarType;
private:
struct ConstHolder
{
explicit ConstHolder(const VectorType& vec)
: element(vec)
{}
const VectorType& element;
}; // struct ConstHolder
public:
explicit VectorInputIterator(const VectorType& vec, const bool end = false)
: const_holder_(std::make_shared<ConstHolder>(vec))
: const_vec_(vec)
, position_(0)
, end_(end)
{}
ThisType& operator++()
{
if (!end_ && position_ < (const_holder_->element.size() - 1))
if (!end_ && position_ < const_vec_.size() - 1)
++position_;
else
end_ = true;
......@@ -78,11 +68,11 @@ public:
{
if (end_)
DUNE_THROW(Common::Exceptions::you_are_using_this_wrong, "This is the end!");
return const_holder_->element[position_];
return const_vec_[position_];
}
private:
std::shared_ptr<ConstHolder> const_holder_;
const VectorType& const_vec_;
protected:
size_t position_;
......@@ -104,30 +94,21 @@ public:
private:
static_assert(std::is_same<ScalarImp, ScalarType>::value, "");
struct Holder
{
explicit Holder(VectorType& vec)
: element(vec)
{}
VectorType& element;
}; // struct Holder
public:
explicit VectorOutputIterator(VectorType& vec, const bool end = false)
: BaseType(vec, end)
, holder_(std::make_shared<Holder>(vec))
, vec_(vec)
{}
ScalarType& operator*()
{
if (this->end_)
DUNE_THROW(Common::Exceptions::you_are_using_this_wrong, "This is the end!");
return holder_->element[this->position_];
return vec_[this->position_];
} // ... operator*()
private:
std::shared_ptr<Holder> holder_;
VectorType& vec_;
}; // class VectorOutputIterator
} // namespace internal
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment