edge InOutEdgesIterator::next() {
  assert(curEdge.isValid());
  // we are already pointing to the next
  edge tmp=curEdge;
  // anticipating the next iteration
  prepareNext();
  return tmp;
}
//===============================================================
SGraphEdgeIterator::SGraphEdgeIterator(const Graph *sG, const MutableContainer<bool>& filter, bool val):FactorEdgeIterator(sG,filter), sg(sG), value(val) {
  it=_parentGraph->getEdges();
#if !defined(NDEBUG) && !defined(_OPENMP)
  _parentGraph->addListener(this);
#endif
  // anticipate first iteration
  prepareNext();
}
node SGraphNodeIterator::next() {
  assert(curNode.isValid());
  // we are already pointing to the next
  node tmp = curNode;
  // anticipate next iteration
  prepareNext();
  return tmp;
}
//===================================================================
InOutEdgesIterator::InOutEdgesIterator(const Graph *sG,const MutableContainer<bool>& filter, node n):FactorEdgeIterator(sG,filter) {
  assert(sG->isElement(n));
  it=_parentGraph->getInOutEdges(n);
#if !defined(NDEBUG) && !defined(_OPENMP)
  _parentGraph->addListener(this);
#endif
  // anticipate first iteration
  prepareNext();
}
 bool hasNext() {
     prepareNext();
     return !arr.empty();
 }
 int next() {
     prepareNext();
     int res = (*arr.top())[pos.top()].getInteger();
     ++pos.top();
     return res;
 }