Go to the documentation of this file.
18 #ifndef LLVM_ADT_BREADTHFIRSTITERATOR_H
19 #define LLVM_ADT_BREADTHFIRSTITERATOR_H
40 template <
typename NodeRef,
unsigned SmallSize = 8>
44 template <
class GraphT,
58 using ChildItTy =
typename GT::ChildIteratorType;
61 using QueueElement = std::pair<NodeRef, Optional<ChildItTy>>;
65 std::queue<Optional<QueueElement>> VisitQueue;
75 VisitQueue.push(QueueElement(
Node,
None));
76 VisitQueue.push(
None);
81 inline void toNext() {
84 NodeRef
Node =
H.first;
89 while (*ChildIt != GT::child_end(
Node)) {
90 NodeRef Next = *(*ChildIt)++;
93 if (this->
Visited.insert(Next).second)
94 VisitQueue.push(QueueElement(Next,
None));
99 if (!VisitQueue.empty()) {
100 Head = VisitQueue.front();
108 if (!VisitQueue.empty())
109 VisitQueue.push(
None);
122 return VisitQueue ==
RHS.VisitQueue;
127 const NodeRef &
operator*()
const {
return VisitQueue.front()->first; }
164 #endif // LLVM_ADT_BREADTHFIRSTITERATOR_H
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
bool operator!=(const bf_iterator &RHS) const
bf_iterator operator++(int)
std::ptrdiff_t difference_type
iterator_range< bf_iterator< T > > breadth_first(const T &G)
typename GT::NodeRef value_type
std::pair< NodeId, LaneBitmask > NodeRef
unsigned getLevel() const
static bf_iterator begin(const GraphT &G)
NodeRef operator->() const
static bf_iterator end(const GraphT &G)
void emplace(ArgTypes &&... Args)
Create a new object by constructing it in place with the given arguments.
constexpr const T & getValue() const &
bf_iterator< T > bf_end(const T &G)
std::forward_iterator_tag iterator_category
bf_iterator< T > bf_begin(const T &G)
bf_iterator & operator++()
A range adaptor for a pair of iterators.
const NodeRef & operator*() const
bool operator==(const bf_iterator &RHS) const