#ifndef SANITIZER_DENSE_MAP_H
#define SANITIZER_DENSE_MAP_H
#include "sanitizer_common.h"
#include "sanitizer_dense_map_info.h"
#include "sanitizer_internal_defs.h"
#include "sanitizer_type_traits.h"
namespace __sanitizer {
template <typename DerivedT, typename KeyT, typename ValueT, typename KeyInfoT,
typename BucketT>
class DenseMapBase { … };
template <typename DerivedT, typename KeyT, typename ValueT, typename KeyInfoT,
typename BucketT>
bool operator==(
const DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT> &LHS,
const DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT> &RHS) { … }
template <typename DerivedT, typename KeyT, typename ValueT, typename KeyInfoT,
typename BucketT>
bool operator!=(
const DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT> &LHS,
const DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT> &RHS) { … }
template <typename KeyT, typename ValueT,
typename KeyInfoT = DenseMapInfo<KeyT>,
typename BucketT = detail::DenseMapPair<KeyT, ValueT>>
class DenseMap : public DenseMapBase<DenseMap<KeyT, ValueT, KeyInfoT, BucketT>,
KeyT, ValueT, KeyInfoT, BucketT> {
friend class DenseMapBase<DenseMap, KeyT, ValueT, KeyInfoT, BucketT>;
using BaseT = DenseMapBase<DenseMap, KeyT, ValueT, KeyInfoT, BucketT>;
BucketT *Buckets = nullptr;
unsigned NumEntries = 0;
unsigned NumTombstones = 0;
unsigned NumBuckets = 0;
public:
explicit DenseMap(unsigned InitialReserve) { … }
constexpr DenseMap() = default;
DenseMap(const DenseMap &other) : … { … }
DenseMap(DenseMap &&other) : … { … }
~DenseMap() { … }
void swap(DenseMap &RHS) { … }
DenseMap &operator=(const DenseMap &other) { … }
DenseMap &operator=(DenseMap &&other) { … }
void copyFrom(const DenseMap &other) { … }
void init(unsigned InitNumEntries) { … }
void grow(unsigned AtLeast) { … }
private:
unsigned getNumEntries() const { … }
void setNumEntries(unsigned Num) { … }
unsigned getNumTombstones() const { … }
void setNumTombstones(unsigned Num) { … }
BucketT *getBuckets() const { … }
unsigned getNumBuckets() const { … }
bool allocateBuckets(unsigned Num) { … }
static void *allocate_buffer(uptr Size) { … }
static void deallocate_buffer(void *Ptr, uptr Size) { … }
};
}
#endif