8#include "EdgeIterator.h"
9#include <pscf/chem/PolymerSpecies.h>
10#include <pscf/chem/Edge.h>
11#include <util/containers/Pair.h>
19 : currentVertexId_(-1),
36 currentEdgeId_ = sourceId;
37 targetEdgeId_ = targetId;
49 p00 = polymerPtr_->
path(s0, t0);
50 p01 = polymerPtr_->
path(s0, t1);
51 p10 = polymerPtr_->
path(s1, t0);
52 p11 = polymerPtr_->
path(s1, t1);
54 if (p00[0] == currentEdgeId_) {
58 currentVertexId_ = s1;
60 if (p10[0] == currentEdgeId_) {
64 currentVertexId_ = s0;
66 UTIL_THROW(
"Error in finding leading vertex for source");
70 p00 = polymerPtr_->
path(t0, s0);
71 p01 = polymerPtr_->
path(t0, s1);
72 p10 = polymerPtr_->
path(t1, s0);
73 p11 = polymerPtr_->
path(t1, s1);
75 if (p00[0] == targetEdgeId_) {
81 if (p10[0] == targetEdgeId_) {
98 Pair<int> propId = polymerPtr_->
path(currentVertexId_, targetVertexId_);
99 int edgeId = propId[0];
100 int dirId = propId[1];
105 Edge const & edge = polymerPtr_->
edge(edgeId);
108 currentEdgeId_ = edgeId;
109 currentVertexId_ = edge.
vertexId(1);
111 currentEdgeId_ = edgeId;
112 currentVertexId_ = edge.
vertexId(0);
121 {
return currentEdgeId_; }
127 {
return currentVertexId_; }
134 return (
bool)( currentVertexId_ == targetVertexId_ );
142 return (
bool)( currentVertexId_ != targetVertexId_ );
Edge iterator for graph associated with a polymer.
int currentVertexId() const
Get index of the current vertex.
int currentEdgeId() const
Get index of the current edge.
~EdgeIterator()
Destructor.
EdgeIterator(PolymerSpecies const &polymer)
Constructor.
bool notEnd() const
Return true iff currentId != targetId.
void begin(int sourceId, int targetId)
Initialize iterator.
EdgeIterator & operator++()
Increment operator - move to next vertex.
bool isEnd() const
Return true iff currentId == targetId.
Descriptor for a block within an acyclic block polymer.
int vertexId(int i) const
Get id of an associated vertex.
Descriptor for a linear or acyclic branched block polymer.
Pair< int > const & path(int is, int it) const
Get an id for a propagator from one vertex towards a target.
virtual Edge & edge(int id)=0
Get a specified Edge (block descriptor) by non-const reference.
An array of exactly 2 objects.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
PSCF package top-level namespace.