LLVM 23.0.0git
llvm::MapVector< KeyT, ValueT, MapType, VectorType, N > Class Template Reference

This class implements a map that also provides access to all stored values in a deterministic order. More...

#include "llvm/ADT/MapVector.h"

Inherited by llvm::SmallMapVector< Value *, SmallVector< Instruction *, 2 >, 8 >, and llvm::SmallMapVector< Instruction *, std::unique_ptr< RematNode >, 8 >.

Public Types

using key_type = KeyT
using value_type = typename VectorType::value_type
using size_type = typename VectorType::size_type
using iterator = typename VectorType::iterator
using const_iterator = typename VectorType::const_iterator
using reverse_iterator = typename VectorType::reverse_iterator
using const_reverse_iterator = typename VectorType::const_reverse_iterator

Public Member Functions

VectorType takeVector ()
 Clear the MapVector and return the underlying vector.
ArrayRef< value_typegetArrayRef () const
 Returns an array reference of the underlying vector.
size_type size () const
void reserve (size_type NumEntries)
 Grow the MapVector so that it can contain at least NumEntries items before resizing again.
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
reverse_iterator rbegin ()
const_reverse_iterator rbegin () const
reverse_iterator rend ()
const_reverse_iterator rend () const
bool empty () const
std::pair< KeyT, ValueT > & front ()
const std::pair< KeyT, ValueT > & front () const
std::pair< KeyT, ValueT > & back ()
const std::pair< KeyT, ValueT > & back () const
void clear ()
void swap (MapVector &RHS)
ValueT & operator[] (const KeyT &Key)
auto keys ()
auto keys () const
auto values ()
auto values () const
ValueT lookup (const KeyT &Key) const
template<typename... Ts>
std::pair< iterator, booltry_emplace (const KeyT &Key, Ts &&...Args)
template<typename... Ts>
std::pair< iterator, booltry_emplace (KeyT &&Key, Ts &&...Args)
std::pair< iterator, boolinsert (const std::pair< KeyT, ValueT > &KV)
std::pair< iterator, boolinsert (std::pair< KeyT, ValueT > &&KV)
template<typename V>
std::pair< iterator, boolinsert_or_assign (const KeyT &Key, V &&Val)
template<typename V>
std::pair< iterator, boolinsert_or_assign (KeyT &&Key, V &&Val)
bool contains (const KeyT &Key) const
size_type count (const KeyT &Key) const
iterator find (const KeyT &Key)
const_iterator find (const KeyT &Key) const
ValueT & at (const KeyT &Key)
 at - Return the entry for the specified key, or abort if no such entry exists.
const ValueT & at (const KeyT &Key) const
 at - Return the entry for the specified key, or abort if no such entry exists.
void pop_back ()
 Remove the last element from the vector.
VectorType::iterator erase (typename VectorType::iterator Iterator)
 Remove the element given by Iterator.
size_type erase (const KeyT &Key)
 Remove all elements with the key value Key.
template<class Predicate>
void remove_if (Predicate Pred)
 Remove the elements that match the predicate.
size_t getMemorySize () const
 Return the approximate size (in bytes) of the data structure.
template<class Function>
void remove_if (Function Pred)

Detailed Description

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
class llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >

This class implements a map that also provides access to all stored values in a deterministic order.

The values are kept in a SmallVector<*, 0> and the mapping is done with DenseMap from Keys to indexes in that vector.

Definition at line 38 of file MapVector.h.

Member Typedef Documentation

◆ const_iterator

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
using llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::const_iterator = typename VectorType::const_iterator

Definition at line 45 of file MapVector.h.

◆ const_reverse_iterator

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
using llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::const_reverse_iterator = typename VectorType::const_reverse_iterator

Definition at line 47 of file MapVector.h.

◆ iterator

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
using llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::iterator = typename VectorType::iterator

Definition at line 44 of file MapVector.h.

◆ key_type

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
using llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::key_type = KeyT

Definition at line 40 of file MapVector.h.

◆ reverse_iterator

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
using llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::reverse_iterator = typename VectorType::reverse_iterator

Definition at line 46 of file MapVector.h.

◆ size_type

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
using llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::size_type = typename VectorType::size_type

Definition at line 42 of file MapVector.h.

◆ value_type

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
using llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::value_type = typename VectorType::value_type

Definition at line 41 of file MapVector.h.

Member Function Documentation

◆ at() [1/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
ValueT & llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::at ( const KeyT & Key)
inlinenodiscard

at - Return the entry for the specified key, or abort if no such entry exists.

Definition at line 176 of file MapVector.h.

◆ at() [2/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
const ValueT & llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::at ( const KeyT & Key) const
inlinenodiscard

at - Return the entry for the specified key, or abort if no such entry exists.

Definition at line 184 of file MapVector.h.

◆ back() [1/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
std::pair< KeyT, ValueT > & llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::back ( )
inlinenodiscard

Definition at line 85 of file MapVector.h.

◆ back() [2/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
const std::pair< KeyT, ValueT > & llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::back ( ) const
inlinenodiscard

Definition at line 86 of file MapVector.h.

◆ begin() [1/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
iterator llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::begin ( )
inlinenodiscard

Definition at line 67 of file MapVector.h.

Referenced by interpretValues(), llvm::UnrollLoop(), and llvm::writeIndex().

◆ begin() [2/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
const_iterator llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::begin ( ) const
inlinenodiscard

Definition at line 68 of file MapVector.h.

◆ clear()

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
void llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::clear ( )
inline

◆ contains()

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
bool llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::contains ( const KeyT & Key) const
inlinenodiscard

◆ count()

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
size_type llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::count ( const KeyT & Key) const
inlinenodiscard

◆ empty()

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
bool llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::empty ( ) const
inlinenodiscard

◆ end() [1/2]

◆ end() [2/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
const_iterator llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::end ( ) const
inlinenodiscard

Definition at line 70 of file MapVector.h.

◆ erase() [1/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
size_type llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::erase ( const KeyT & Key)
inline

Remove all elements with the key value Key.

Returns the number of elements removed.

Definition at line 233 of file MapVector.h.

◆ erase() [2/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
VectorType::iterator llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::erase ( typename VectorType::iterator Iterator)
inline

Remove the element given by Iterator.

Returns an iterator to the element following the one which was removed, which may be end().

Note
This is a deceivingly expensive operation (linear time). It's usually better to use remove_if() if possible.

Definition at line 210 of file MapVector.h.

Referenced by collectCallSiteParameters(), llvm::MapVector< StringRef, HashData >::erase(), and interpretValues().

◆ find() [1/2]

◆ find() [2/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
const_iterator llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::find ( const KeyT & Key) const
inlinenodiscard

Definition at line 165 of file MapVector.h.

◆ front() [1/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
std::pair< KeyT, ValueT > & llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::front ( )
inlinenodiscard

◆ front() [2/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
const std::pair< KeyT, ValueT > & llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::front ( ) const
inlinenodiscard

Definition at line 82 of file MapVector.h.

◆ getArrayRef()

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
ArrayRef< value_type > llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::getArrayRef ( ) const
inlinenodiscard

Returns an array reference of the underlying vector.

Definition at line 56 of file MapVector.h.

◆ getMemorySize()

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
size_t llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::getMemorySize ( ) const
inlinenodiscard

Return the approximate size (in bytes) of the data structure.

This is just the raw memory used by MapVector. If entries are pointers to objects, the size of the referenced objects are not included.

Definition at line 251 of file MapVector.h.

◆ insert() [1/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
std::pair< iterator, bool > llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::insert ( const std::pair< KeyT, ValueT > & KV)
inline

◆ insert() [2/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
std::pair< iterator, bool > llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::insert ( std::pair< KeyT, ValueT > && KV)
inline

Definition at line 129 of file MapVector.h.

◆ insert_or_assign() [1/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
template<typename V>
std::pair< iterator, bool > llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::insert_or_assign ( const KeyT & Key,
V && Val )
inline

Definition at line 134 of file MapVector.h.

◆ insert_or_assign() [2/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
template<typename V>
std::pair< iterator, bool > llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::insert_or_assign ( KeyT && Key,
V && Val )
inline

Definition at line 141 of file MapVector.h.

◆ keys() [1/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
auto llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::keys ( )
inlinenodiscard

Definition at line 104 of file MapVector.h.

◆ keys() [2/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
auto llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::keys ( ) const
inlinenodiscard

Definition at line 105 of file MapVector.h.

◆ lookup()

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
ValueT llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::lookup ( const KeyT & Key) const
inlinenodiscard

◆ operator[]()

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
ValueT & llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::operator[] ( const KeyT & Key)
inline

Definition at line 100 of file MapVector.h.

Referenced by llvm::ScheduleDAGInstrs::Value2SUsMap::insert().

◆ pop_back()

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
void llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::pop_back ( )
inline

Remove the last element from the vector.

Definition at line 191 of file MapVector.h.

◆ rbegin() [1/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
reverse_iterator llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::rbegin ( )
inlinenodiscard

Definition at line 72 of file MapVector.h.

Referenced by llvm::InterleavedAccessInfo::analyzeInterleaving().

◆ rbegin() [2/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
const_reverse_iterator llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::rbegin ( ) const
inlinenodiscard

Definition at line 73 of file MapVector.h.

◆ remove_if() [1/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
template<class Function>
void llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::remove_if ( Function Pred)

Definition at line 312 of file MapVector.h.

◆ remove_if() [2/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
template<class Predicate>
void llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::remove_if ( Predicate Pred)

Remove the elements that match the predicate.

Erase all elements that match Pred in a single pass. Takes linear time.

◆ rend() [1/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
reverse_iterator llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::rend ( )
inlinenodiscard

Definition at line 76 of file MapVector.h.

Referenced by llvm::InterleavedAccessInfo::analyzeInterleaving().

◆ rend() [2/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
const_reverse_iterator llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::rend ( ) const
inlinenodiscard

Definition at line 77 of file MapVector.h.

◆ reserve()

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
void llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::reserve ( size_type NumEntries)
inline

Grow the MapVector so that it can contain at least NumEntries items before resizing again.

Definition at line 62 of file MapVector.h.

◆ size()

◆ swap()

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
void llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::swap ( MapVector< KeyT, ValueT, MapType, VectorType, N > & RHS)
inline

Definition at line 95 of file MapVector.h.

◆ takeVector()

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
VectorType llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::takeVector ( )
inlinenodiscard

Clear the MapVector and return the underlying vector.

Definition at line 50 of file MapVector.h.

Referenced by computeFunctionSummary().

◆ try_emplace() [1/2]

◆ try_emplace() [2/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
template<typename... Ts>
std::pair< iterator, bool > llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::try_emplace ( KeyT && Key,
Ts &&... Args )
inline

Definition at line 122 of file MapVector.h.

◆ values() [1/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
auto llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::values ( )
inlinenodiscard

Definition at line 106 of file MapVector.h.

◆ values() [2/2]

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>, unsigned N = 0>
auto llvm::MapVector< KeyT, ValueT, MapType, VectorType, N >::values ( ) const
inlinenodiscard

Definition at line 107 of file MapVector.h.


The documentation for this class was generated from the following file: