33 #ifndef LLVM_ADT_DEPTHFIRSTITERATOR_H
34 #define LLVM_ADT_DEPTHFIRSTITERATOR_H
46 template<
class SetType,
bool External>
52 template<
class SetType>
62 template<
class GraphT,
65 class df_iterator :
public std::iterator<std::forward_iterator_tag,
66 typename GT::NodeType, ptrdiff_t>,
68 typedef std::iterator<std::forward_iterator_tag,
72 typedef typename GT::ChildIteratorType ChildItTy;
78 std::vector<std::pair<PointerIntTy, ChildItTy> > VisitStack;
82 VisitStack.push_back(std::make_pair(
PointerIntTy(Node, 0),
83 GT::child_begin(Node)));
91 VisitStack.push_back(std::make_pair(
PointerIntTy(Node, 0),
92 GT::child_begin(Node)));
101 inline void toNext() {
103 std::pair<PointerIntTy, ChildItTy> &Top = VisitStack.back();
104 NodeType *Node = Top.first.getPointer();
105 ChildItTy &It = Top.second;
106 if (!Top.first.getInt()) {
108 It = GT::child_begin(Node);
112 while (It != GT::child_end(Node)) {
113 NodeType *Next = *It++;
115 if (Next && !this->
Visited.count(Next)) {
118 VisitStack.push_back(std::make_pair(
PointerIntTy(Next, 0),
119 GT::child_begin(Next)));
125 VisitStack.pop_back();
126 }
while (!VisitStack.empty());
135 return _Self(GT::getEntryNode(G));
141 return _Self(GT::getEntryNode(G), S);
146 return VisitStack == x.VisitStack;
151 return VisitStack.back().first.getPointer();
168 VisitStack.pop_back();
169 if (!VisitStack.empty())
175 _Self tmp = *
this; ++*
this;
return tmp;
183 return this->
Visited.count(Node) != 0;
193 return VisitStack[n].first.getPointer();
217 template <
class T,
class SetTy>
222 template <
class T,
class SetTy>
231 bool External =
false>
256 template <
class T,
class SetTy>
261 template <
class T,
class SetTy>
static _Self begin(const GraphT &G, SetType &S)
pointer operator*() const
bool operator!=(const _Self &x) const
idf_iterator(const df_iterator< Inverse< T >, SetTy, External > &V)
static _Self begin(const GraphT &G)
idf_iterator< T > idf_begin(const T &G)
idf_iterator< T > idf_end(const T &G)
NodeType * operator->() const
df_ext_iterator< T, SetTy > df_ext_end(const T &G, SetTy &S)
df_iterator< T > df_end(const T &G)
idf_ext_iterator< T, SetTy > idf_ext_end(const T &G, SetTy &S)
df_ext_iterator< T, SetTy > df_ext_begin(const T &G, SetTy &S)
bool operator==(const _Self &x) const
idf_ext_iterator(const idf_iterator< T, SetTy, true > &V)
idf_ext_iterator< T, SetTy > idf_ext_begin(const T &G, SetTy &S)
df_ext_iterator(const df_iterator< T, SetTy, true > &V)
static _Self end(const GraphT &G, SetType &S)
static _Self end(const GraphT &G)
df_iterator_storage(const df_iterator_storage &S)
df_iterator< T > df_begin(const T &G)
df_iterator_storage(SetType &VSet)
df_iterator< GraphT, SetType, ExtStorage, GT > _Self
idf_ext_iterator(const df_iterator< Inverse< T >, SetTy, true > &V)
NodeType * getPath(unsigned n) const
unsigned getPathLength() const
bool nodeVisited(NodeType *Node) const