WPILibC++ 2023.4.3
wpi::MapVector< KeyT, ValueT, MapType, VectorType > Class Template Reference

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

#include </home/runner/work/allwpilib/allwpilib/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MapVector.h>

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. More...
 
size_type size () const
 
void reserve (size_type NumEntries)
 Grow the MapVector so that it can contain at least NumEntries items before resizing again. More...
 
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)
 
ValueT lookup (const KeyT &Key) const
 
std::pair< iterator, bool > insert (const std::pair< KeyT, ValueT > &KV)
 
std::pair< iterator, bool > insert (std::pair< KeyT, ValueT > &&KV)
 
size_type count (const KeyT &Key) const
 
iterator find (const KeyT &Key)
 
const_iterator find (const KeyT &Key) const
 
void pop_back ()
 Remove the last element from the vector. More...
 
VectorType::iterator erase (typename VectorType::iterator Iterator)
 Remove the element given by Iterator. More...
 
size_type erase (const KeyT &Key)
 Remove all elements with the key value Key. More...
 
template<class Predicate >
void remove_if (Predicate Pred)
 Remove the elements that match the predicate. More...
 
template<class Function >
void remove_if (Function Pred)
 

Detailed Description

template<typename KeyT, typename ValueT, typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
class wpi::MapVector< KeyT, ValueT, MapType, VectorType >

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

The values are kept in a std::vector and the mapping is done with DenseMap from Keys to indexes in that vector.

Member Typedef Documentation

◆ const_iterator

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
using wpi::MapVector< KeyT, ValueT, MapType, VectorType >::const_iterator = typename VectorType::const_iterator

◆ const_reverse_iterator

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
using wpi::MapVector< KeyT, ValueT, MapType, VectorType >::const_reverse_iterator = typename VectorType::const_reverse_iterator

◆ iterator

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
using wpi::MapVector< KeyT, ValueT, MapType, VectorType >::iterator = typename VectorType::iterator

◆ key_type

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
using wpi::MapVector< KeyT, ValueT, MapType, VectorType >::key_type = KeyT

◆ reverse_iterator

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
using wpi::MapVector< KeyT, ValueT, MapType, VectorType >::reverse_iterator = typename VectorType::reverse_iterator

◆ size_type

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
using wpi::MapVector< KeyT, ValueT, MapType, VectorType >::size_type = typename VectorType::size_type

◆ value_type

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
using wpi::MapVector< KeyT, ValueT, MapType, VectorType >::value_type = typename VectorType::value_type

Member Function Documentation

◆ back() [1/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
std::pair< KeyT, ValueT > & wpi::MapVector< KeyT, ValueT, MapType, VectorType >::back ( )
inline

◆ back() [2/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
const std::pair< KeyT, ValueT > & wpi::MapVector< KeyT, ValueT, MapType, VectorType >::back ( ) const
inline

◆ begin() [1/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
iterator wpi::MapVector< KeyT, ValueT, MapType, VectorType >::begin ( )
inline

◆ begin() [2/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
const_iterator wpi::MapVector< KeyT, ValueT, MapType, VectorType >::begin ( ) const
inline

◆ clear()

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
void wpi::MapVector< KeyT, ValueT, MapType, VectorType >::clear ( )
inline

◆ count()

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
size_type wpi::MapVector< KeyT, ValueT, MapType, VectorType >::count ( const KeyT &  Key) const
inline

◆ empty()

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
bool wpi::MapVector< KeyT, ValueT, MapType, VectorType >::empty ( ) const
inline

◆ end() [1/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
iterator wpi::MapVector< KeyT, ValueT, MapType, VectorType >::end ( )
inline

◆ end() [2/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
const_iterator wpi::MapVector< KeyT, ValueT, MapType, VectorType >::end ( ) const
inline

◆ erase() [1/2]

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

Remove all elements with the key value Key.

Returns the number of elements removed.

◆ erase() [2/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
VectorType::iterator wpi::MapVector< KeyT, ValueT, MapType, VectorType >::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.

◆ find() [1/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
iterator wpi::MapVector< KeyT, ValueT, MapType, VectorType >::find ( const KeyT &  Key)
inline

◆ find() [2/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
const_iterator wpi::MapVector< KeyT, ValueT, MapType, VectorType >::find ( const KeyT &  Key) const
inline

◆ front() [1/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
std::pair< KeyT, ValueT > & wpi::MapVector< KeyT, ValueT, MapType, VectorType >::front ( )
inline

◆ front() [2/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
const std::pair< KeyT, ValueT > & wpi::MapVector< KeyT, ValueT, MapType, VectorType >::front ( ) const
inline

◆ insert() [1/2]

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

◆ insert() [2/2]

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

◆ lookup()

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
ValueT wpi::MapVector< KeyT, ValueT, MapType, VectorType >::lookup ( const KeyT &  Key) const
inline

◆ operator[]()

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

◆ pop_back()

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
void wpi::MapVector< KeyT, ValueT, MapType, VectorType >::pop_back ( )
inline

Remove the last element from the vector.

◆ rbegin() [1/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
reverse_iterator wpi::MapVector< KeyT, ValueT, MapType, VectorType >::rbegin ( )
inline

◆ rbegin() [2/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
const_reverse_iterator wpi::MapVector< KeyT, ValueT, MapType, VectorType >::rbegin ( ) const
inline

◆ remove_if() [1/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
template<class Function >
void wpi::MapVector< KeyT, ValueT, MapType, VectorType >::remove_if ( Function  Pred)

◆ remove_if() [2/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
template<class Predicate >
void wpi::MapVector< KeyT, ValueT, MapType, VectorType >::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 = std::vector<std::pair<KeyT, ValueT>>>
reverse_iterator wpi::MapVector< KeyT, ValueT, MapType, VectorType >::rend ( )
inline

◆ rend() [2/2]

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
const_reverse_iterator wpi::MapVector< KeyT, ValueT, MapType, VectorType >::rend ( ) const
inline

◆ reserve()

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
void wpi::MapVector< KeyT, ValueT, MapType, VectorType >::reserve ( size_type  NumEntries)
inline

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

◆ size()

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
size_type wpi::MapVector< KeyT, ValueT, MapType, VectorType >::size ( ) const
inline

◆ swap()

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
void wpi::MapVector< KeyT, ValueT, MapType, VectorType >::swap ( MapVector< KeyT, ValueT, MapType, VectorType > &  RHS)
inline

◆ takeVector()

template<typename KeyT , typename ValueT , typename MapType = DenseMap<KeyT, unsigned>, typename VectorType = std::vector<std::pair<KeyT, ValueT>>>
VectorType wpi::MapVector< KeyT, ValueT, MapType, VectorType >::takeVector ( )
inline

Clear the MapVector and return the underlying vector.


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