LLVM
8.0.1
|
A FILO worklist that prioritizes on re-insertion without duplication. More...
#include "llvm/ADT/PriorityWorklist.h"
Public Types | |
using | value_type = T |
using | key_type = T |
using | reference = T & |
using | const_reference = const T & |
using | size_type = typename MapT::size_type |
Public Member Functions | |
PriorityWorklist ()=default | |
Construct an empty PriorityWorklist. More... | |
bool | empty () const |
Determine if the PriorityWorklist is empty or not. More... | |
size_type | size () const |
Returns the number of elements in the worklist. More... | |
size_type | count (const key_type &key) const |
Count the number of elements of a given key in the PriorityWorklist. More... | |
const T & | back () const |
Return the last element of the PriorityWorklist. More... | |
bool | insert (const T &X) |
Insert a new element into the PriorityWorklist. More... | |
template<typename SequenceT > | |
std::enable_if<!std::is_convertible< SequenceT, T >::value >::type | insert (SequenceT &&Input) |
Insert a sequence of new elements into the PriorityWorklist. More... | |
void | pop_back () |
Remove the last element of the PriorityWorklist. More... | |
LLVM_NODISCARD T | pop_back_val () |
bool | erase (const T &X) |
Erase an item from the worklist. More... | |
template<typename UnaryPredicate > | |
bool | erase_if (UnaryPredicate P) |
Erase items from the set vector based on a predicate function. More... | |
void | clear () |
Reverse the items in the PriorityWorklist. More... | |
A FILO worklist that prioritizes on re-insertion without duplication.
This is very similar to a SetVector
with the primary difference that while re-insertion does not create a duplicate, it does adjust the visitation order to respect the last insertion point. This can be useful when the visit order needs to be prioritized based on insertion point without actually having duplicate visits.
Note that this doesn't prevent re-insertion of elements which have been visited – if you need to break cycles, a set will still be necessary.
The type T
must be default constructable to a null value that will be ignored. It is an error to insert such a value, and popping elements will never produce such a value. It is expected to be used with common nullable types like pointers or optionals.
Internally this uses a vector to store the worklist and a map to identify existing elements in the worklist. Both of these may be customized, but the map must support the basic DenseMap API for mapping from a T to an integer index into the vector.
A partial specialization is provided to automatically select a SmallVector and a SmallDenseMap if custom data structures are not provided.
Definition at line 57 of file PriorityWorklist.h.
using llvm::PriorityWorklist< T, VectorT, MapT >::const_reference = const T& |
Definition at line 62 of file PriorityWorklist.h.
using llvm::PriorityWorklist< T, VectorT, MapT >::key_type = T |
Definition at line 60 of file PriorityWorklist.h.
using llvm::PriorityWorklist< T, VectorT, MapT >::reference = T& |
Definition at line 61 of file PriorityWorklist.h.
using llvm::PriorityWorklist< T, VectorT, MapT >::size_type = typename MapT::size_type |
Definition at line 63 of file PriorityWorklist.h.
using llvm::PriorityWorklist< T, VectorT, MapT >::value_type = T |
Definition at line 59 of file PriorityWorklist.h.
|
default |
Construct an empty PriorityWorklist.
|
inline |
Return the last element of the PriorityWorklist.
Definition at line 85 of file PriorityWorklist.h.
Referenced by llvm::PriorityWorklist< llvm::LazyCallGraph::SCC *, SmallVector< llvm::LazyCallGraph::SCC *, N >, SmallDenseMap< llvm::LazyCallGraph::SCC *, ptrdiff_t > >::pop_back(), and llvm::PriorityWorklist< llvm::LazyCallGraph::SCC *, SmallVector< llvm::LazyCallGraph::SCC *, N >, SmallDenseMap< llvm::LazyCallGraph::SCC *, ptrdiff_t > >::pop_back_val().
|
inline |
Reverse the items in the PriorityWorklist.
This does an in-place reversal. Other kinds of reverse aren't easy to support in the face of the worklist semantics. Completely clear the PriorityWorklist
Definition at line 213 of file PriorityWorklist.h.
|
inline |
Count the number of elements of a given key in the PriorityWorklist.
Definition at line 80 of file PriorityWorklist.h.
|
inline |
Determine if the PriorityWorklist is empty or not.
Definition at line 69 of file PriorityWorklist.h.
Referenced by llvm::PriorityWorklist< llvm::LazyCallGraph::SCC *, SmallVector< llvm::LazyCallGraph::SCC *, N >, SmallDenseMap< llvm::LazyCallGraph::SCC *, ptrdiff_t > >::back(), and llvm::PriorityWorklist< llvm::LazyCallGraph::SCC *, SmallVector< llvm::LazyCallGraph::SCC *, N >, SmallDenseMap< llvm::LazyCallGraph::SCC *, ptrdiff_t > >::pop_back().
|
inline |
Erase an item from the worklist.
Note that this is constant time due to the nature of the worklist implementation.
Definition at line 164 of file PriorityWorklist.h.
|
inline |
Erase items from the set vector based on a predicate function.
This is intended to be equivalent to the following code, if we could write it:
However, PriorityWorklist doesn't expose non-const iterators, making any algorithm like remove_if impossible to use.
Definition at line 195 of file PriorityWorklist.h.
|
inline |
Insert a new element into the PriorityWorklist.
Definition at line 92 of file PriorityWorklist.h.
|
inline |
Insert a sequence of new elements into the PriorityWorklist.
Definition at line 115 of file PriorityWorklist.h.
|
inline |
Remove the last element of the PriorityWorklist.
Definition at line 146 of file PriorityWorklist.h.
|
inline |
Definition at line 155 of file PriorityWorklist.h.
|
inline |
Returns the number of elements in the worklist.
Definition at line 74 of file PriorityWorklist.h.