18 #ifndef LLVM_ADT_BREADTHFIRSTITERATOR_H 19 #define LLVM_ADT_BREADTHFIRSTITERATOR_H 40 template <
typename NodeRef,
unsigned SmallSize = 8>
44 template <
class GraphT,
49 :
public std::iterator<std::forward_iterator_tag, typename GT::NodeRef>,
51 using super = std::iterator<std::forward_iterator_tag, typename GT::NodeRef>;
53 using NodeRef =
typename GT::NodeRef;
54 using ChildItTy =
typename GT::ChildIteratorType;
57 using QueueElement = std::pair<NodeRef, Optional<ChildItTy>>;
61 std::queue<Optional<QueueElement>> VisitQueue;
72 VisitQueue.push(QueueElement(Node,
None));
73 VisitQueue.push(
None);
78 inline void toNext() {
81 NodeRef Node = H.first;
85 ChildIt.
emplace(GT::child_begin(Node));
86 while (*ChildIt != GT::child_end(Node)) {
87 NodeRef Next = *(*ChildIt)++;
90 if (this->
Visited.insert(Next).second)
91 VisitQueue.push(QueueElement(Next,
None));
96 if (!VisitQueue.empty()) {
97 Head = VisitQueue.front();
105 if (!VisitQueue.empty())
106 VisitQueue.push(
None);
121 return VisitQueue == RHS.VisitQueue;
126 const NodeRef &
operator*()
const {
return VisitQueue.front()->first; }
163 #endif // LLVM_ADT_BREADTHFIRSTITERATOR_H This class represents lattice values for constants.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
bf_iterator< T > bf_begin(const T &G)
void emplace(ArgTypes &&... Args)
Create a new object by constructing it in place with the given arguments.
bf_iterator & operator++()
iterator_range< bf_iterator< T > > breadth_first(const T &G)
typename super::pointer pointer
static bf_iterator end(const GraphT &G)
static bf_iterator begin(const GraphT &G)
const T & getValue() const LLVM_LVALUE_FUNCTION
bool operator!=(const bf_iterator &RHS) const
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
unsigned getLevel() const
A range adaptor for a pair of iterators.
bf_iterator< T > bf_end(const T &G)
bool operator==(const bf_iterator &RHS) const
const NodeRef & operator*() const
NodeRef operator->() const
bf_iterator operator++(int)