#ifndef LLVM_ADT_MAPVECTOR_H
#define LLVM_ADT_MAPVECTOR_H
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include <cassert>
#include <cstddef>
#include <iterator>
#include <type_traits>
#include <utility>
namespace llvm {
template <typename KeyT, typename ValueT,
typename MapType = DenseMap<KeyT, unsigned>,
typename VectorType = SmallVector<std::pair<KeyT, ValueT>, 0>>
class MapVector {
MapType Map;
VectorType Vector;
static_assert(
std::is_integral_v<typename MapType::mapped_type>,
"The mapped_type of the specified Map must be an integral type");
public:
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;
VectorType takeVector() { … }
size_type size() const { … }
void reserve(size_type NumEntries) { … }
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 { … }
template <typename... Ts>
std::pair<iterator, bool> try_emplace(const KeyT &Key, Ts &&...Args) { … }
template <typename... Ts>
std::pair<iterator, bool> try_emplace(KeyT &&Key, Ts &&...Args) { … }
std::pair<iterator, bool> insert(const std::pair<KeyT, ValueT> &KV) { … }
std::pair<iterator, bool> insert(std::pair<KeyT, ValueT> &&KV) { … }
template <typename V>
std::pair<iterator, bool> insert_or_assign(const KeyT &Key, V &&Val) { … }
template <typename V>
std::pair<iterator, bool> insert_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 { … }
void pop_back() { … }
typename VectorType::iterator erase(typename VectorType::iterator Iterator) { … }
size_type erase(const KeyT &Key) { … }
template <class Predicate> void remove_if(Predicate Pred);
};
template <typename KeyT, typename ValueT, typename MapType, typename VectorType>
template <class Function>
void MapVector<KeyT, ValueT, MapType, VectorType>::remove_if(Function Pred) { … }
template <typename KeyT, typename ValueT, unsigned N>
struct SmallMapVector
: MapVector<KeyT, ValueT, SmallDenseMap<KeyT, unsigned, N>,
SmallVector<std::pair<KeyT, ValueT>, N>> { … };
}
#endif