* src/graph/graph.hh (trans_iterator): Respect the forward_iterator API.
This commit is contained in:
parent
ac98d7c006
commit
1c0a93cc0f
1 changed files with 25 additions and 10 deletions
|
|
@ -25,6 +25,7 @@
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
|
@ -172,13 +173,29 @@ namespace spot
|
||||||
// of that list.
|
// of that list.
|
||||||
|
|
||||||
template <typename Graph>
|
template <typename Graph>
|
||||||
class SPOT_API trans_iterator
|
class SPOT_API trans_iterator:
|
||||||
|
std::iterator<std::forward_iterator_tag,
|
||||||
|
typename
|
||||||
|
std::conditional<std::is_const<Graph>::value,
|
||||||
|
const typename Graph::trans_storage_t,
|
||||||
|
typename Graph::trans_storage_t>::type>
|
||||||
{
|
{
|
||||||
|
typedef
|
||||||
|
std::iterator<std::forward_iterator_tag,
|
||||||
|
typename
|
||||||
|
std::conditional<std::is_const<Graph>::value,
|
||||||
|
const typename Graph::trans_storage_t,
|
||||||
|
typename Graph::trans_storage_t>::type>
|
||||||
|
super;
|
||||||
public:
|
public:
|
||||||
typedef typename Graph::transition transition;
|
typedef typename Graph::transition transition;
|
||||||
typedef typename Graph::trans_storage_t trans_storage_t;
|
|
||||||
|
|
||||||
trans_iterator(Graph* g, transition t): t_(t), g_(g)
|
trans_iterator()
|
||||||
|
: g_(nullptr), t_(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
trans_iterator(Graph* g, transition t): g_(g), t_(t)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,9 +209,7 @@ namespace spot
|
||||||
return t_ != o.t_;
|
return t_ != o.t_;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename std::conditional<std::is_const<Graph>::value,
|
typename super::reference
|
||||||
const trans_storage_t&,
|
|
||||||
trans_storage_t&>::type
|
|
||||||
operator*()
|
operator*()
|
||||||
{
|
{
|
||||||
return g_->trans_storage(t_);
|
return g_->trans_storage(t_);
|
||||||
|
|
@ -214,8 +229,8 @@ namespace spot
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
transition t_;
|
|
||||||
Graph* g_;
|
Graph* g_;
|
||||||
|
transition t_;
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
|
@ -230,7 +245,7 @@ namespace spot
|
||||||
public:
|
public:
|
||||||
typedef typename Graph::transition transition;
|
typedef typename Graph::transition transition;
|
||||||
state_out(Graph* g, transition t):
|
state_out(Graph* g, transition t):
|
||||||
t_(t), g_(g)
|
g_(g), t_(t)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -241,7 +256,7 @@ namespace spot
|
||||||
|
|
||||||
trans_iterator<Graph> end()
|
trans_iterator<Graph> end()
|
||||||
{
|
{
|
||||||
return {nullptr, 0};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void recycle(transition t)
|
void recycle(transition t)
|
||||||
|
|
@ -250,8 +265,8 @@ namespace spot
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
transition t_;
|
|
||||||
Graph* g_;
|
Graph* g_;
|
||||||
|
transition t_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue