15#ifndef LLVM_ADT_PRIORITYWORKLIST_H
16#define LLVM_ADT_PRIORITYWORKLIST_H
53template <
typename T,
typename VectorT = std::vector<T>,
54 typename MapT = DenseMap<T, ptrdiff_t>>
84 assert(!
empty() &&
"Cannot call back() on empty PriorityWorklist!");
91 assert(
X !=
T() &&
"Cannot insert a null (default constructed) value!");
92 auto InsertResult = M.insert({
X, V.size()});
93 if (InsertResult.second) {
99 auto &Index = InsertResult.first->second;
100 assert(V[Index] ==
X &&
"Value not actually at index in map!");
101 if (Index != (
ptrdiff_t)(V.size() - 1)) {
111 template <
typename SequenceT>
112 std::enable_if_t<!std::is_convertible<SequenceT, T>::value>
121 V.insert(V.end(), std::begin(
Input), std::end(
Input));
123 for (
ptrdiff_t i = V.size() - 1; i >= StartIndex; --i) {
124 auto InsertResult = M.insert({V[i], i});
125 if (InsertResult.second)
130 ptrdiff_t &Index = InsertResult.first->second;
131 if (Index < StartIndex) {
145 assert(!
empty() &&
"Cannot remove an element when empty!");
146 assert(
back() !=
T() &&
"Cannot have a null element at the back!");
150 }
while (!V.empty() && V.back() ==
T());
167 assert(V[
I->second] ==
X &&
"Value not actually at index in map!");
171 }
while (!V.empty() && V.back() ==
T());
192 template <
typename UnaryPredicate>
194 typename VectorT::iterator
E =
remove_if(V, [&](
const T &Arg) {
207 for (
auto I = V.begin();
I !=
E; ++
I)
209 M[*
I] =
I - V.begin();
235template <
typename T,
unsigned N>
238 SmallDenseMap<T, ptrdiff_t>> {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
This file defines the SmallVector class.
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
const T & back() const
Return the last element of the PriorityWorklist.
const T & const_reference
PriorityWorklist()=default
Construct an empty PriorityWorklist.
size_type count(const key_type &key) const
Count the number of elements of a given key in the PriorityWorklist.
void clear()
Reverse the items in the PriorityWorklist.
typename MapT::size_type size_type
size_type size() const
Returns the number of elements in the worklist.
bool erase_if(UnaryPredicate P)
Erase items from the set vector based on a predicate function.
bool erase(const T &X)
Erase an item from the worklist.
void pop_back()
Remove the last element of the PriorityWorklist.
bool empty() const
Determine if the PriorityWorklist is empty or not.
bool insert(const T &X)
Insert a new element into the PriorityWorklist.
std::enable_if_t<!std::is_convertible< SequenceT, T >::value > insert(SequenceT &&Input)
Insert a sequence of new elements into the PriorityWorklist.
SmallPriorityWorklist()=default
This is an optimization pass for GlobalISel generic memory operations.
auto remove_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly.