define iteration on ScopePath as reverse iteration on the contained Scopes
This commit is contained in:
parent
b2849c6099
commit
b7987cf3ce
3 changed files with 39 additions and 3 deletions
|
|
@ -309,8 +309,8 @@ namespace lib {
|
|||
{ }
|
||||
|
||||
RangeIter ()
|
||||
: p_(0)
|
||||
, e_(0)
|
||||
: p_()
|
||||
, e_()
|
||||
{ }
|
||||
|
||||
|
||||
|
|
@ -358,7 +358,7 @@ namespace lib {
|
|||
bool
|
||||
isValid () const
|
||||
{
|
||||
return (p_!= IT(0)) && (p_ != e_);
|
||||
return (p_!= IT()) && (p_ != e_);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
//#include "proc/mobject/mobject.hpp"
|
||||
//#include "proc/mobject/placement-ref.hpp"
|
||||
#include "proc/mobject/session/scope.hpp"
|
||||
#include "lib/iter-adapter.hpp"
|
||||
|
||||
#include <vector>
|
||||
//#include <string>
|
||||
|
|
@ -46,9 +47,17 @@ namespace session {
|
|||
{
|
||||
vector<Scope> path_;
|
||||
|
||||
typedef vector<Scope> _VType;
|
||||
typedef _VType::const_reverse_iterator _VIter;
|
||||
typedef lib::RangeIter<_VIter> _IterType;
|
||||
|
||||
public:
|
||||
ScopePath();
|
||||
|
||||
/// Iteration is always ascending from leaf to root
|
||||
typedef _IterType iterator;
|
||||
iterator begin() const;
|
||||
iterator end() const;
|
||||
|
||||
Scope getLeaf() const;
|
||||
|
||||
|
|
@ -58,5 +67,18 @@ namespace session {
|
|||
///////////////////////////TODO currently just fleshing the API
|
||||
|
||||
|
||||
inline ScopePath::iterator
|
||||
ScopePath::begin() const
|
||||
{
|
||||
return iterator (path_.rbegin(), path_.rend());
|
||||
}
|
||||
|
||||
inline ScopePath::iterator
|
||||
ScopePath::end() const
|
||||
{
|
||||
return iterator();
|
||||
}
|
||||
|
||||
|
||||
}} // namespace mobject::session
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -95,6 +95,20 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
checkIteration (ScopePath path, PMO& refPlacement)
|
||||
{
|
||||
Scope refScope(refPlacement);
|
||||
ScopePath::iterator ii = path.begin();
|
||||
ASSERT (ii);
|
||||
while (++ii)
|
||||
{
|
||||
ASSERT (*ii == refScope.getParent());
|
||||
refScope = *ii;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
checkRelations (ScopePath path1, PMO& refPlacement)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue