#pragma once
#include <cmath>
#include <cassert>
#include <limits>
#include <memory>
#include <map>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <iterator>
#include <type_traits>
#include <optional>
#include <utility>
#ifdef USE_ROBIN_HOOD_HASHING
#include "robin_hood.h"
#else
#include <unordered_set>
#endif
#include <vulkan/utility/vk_concurrent_unordered_map.hpp>
namespace vvl {
#ifdef USE_ROBIN_HOOD_HASHING
template <typename T>
using hash = robin_hood::hash<T>;
template <typename Key, typename Hash = robin_hood::hash<Key>, typename KeyEqual = std::equal_to<Key>>
using unordered_set = robin_hood::unordered_set<Key, Hash, KeyEqual>;
template <typename Key, typename T, typename Hash = robin_hood::hash<Key>, typename KeyEqual = std::equal_to<Key>>
using unordered_map = robin_hood::unordered_map<Key, T, Hash, KeyEqual>;
template <typename Key, typename T>
using map_entry = robin_hood::pair<Key, T>;
template <typename T>
struct insert_iterator {
using iterator_category = std::output_iterator_tag;
using value_type = typename T::value_type;
using iterator = typename T::iterator;
using difference_type = void;
using pointer = void;
using reference = T &;
insert_iterator(reference t, iterator i) : container(&t), iter(i) {}
insert_iterator &operator=(const value_type &value) {
auto result = container->insert(value);
iter = result.first;
++iter;
return *this;
}
insert_iterator &operator=(value_type &&value) {
auto result = container->insert(std::move(value));
iter = result.first;
++iter;
return *this;
}
insert_iterator &operator*() { return *this; }
insert_iterator &operator++() { return *this; }
insert_iterator &operator++(int) { return *this; }
private:
T *container;
iterator iter;
};
#else
hash;
unordered_set;
unordered_map;
map_entry;
insert_iterator;
#endif
#if 1
concurrent_unordered_map;
#else
template <typename Key, typename T, int BucketsLog2 = 2>
using concurrent_unordered_map = vku::concurrent_unordered_map<Key, T, BucketsLog2, vvl::unordered_map<Key, T>>;
#endif
}
template <typename T, size_t N, typename SizeType = uint32_t>
class small_vector { … };
template <typename Key, typename value_type, typename inner_container_type, typename value_type_helper, int N>
class small_container { … };
template <typename MapType>
class value_type_helper_map { … };
template <typename Key>
class value_type_helper_set { … };
template <typename Key, typename T, int N = 1>
class small_unordered_map : public small_container<Key, typename vvl::unordered_map<Key, T>::value_type, vvl::unordered_map<Key, T>,
value_type_helper_map<vvl::unordered_map<Key, T>>, N> { … };
template <typename Key, int N = 1>
class small_unordered_set : public small_container<Key, Key, vvl::unordered_set<Key>, value_type_helper_set<Key>, N> { … };
template <typename DATA_T>
DATA_T *GetLayerDataPtr(void *data_key, small_unordered_map<void *, DATA_T *, 2> &layer_data_map) { … }
template <typename DATA_T>
void FreeLayerDataPtr(void *data_key, small_unordered_map<void *, DATA_T *, 2> &layer_data_map) { … }
template <typename DATA_T>
DATA_T *GetLayerDataPtr(void *data_key, std::unordered_map<void *, DATA_T *> &layer_data_map) { … }
template <typename DATA_T>
void FreeLayerDataPtr(void *data_key, std::unordered_map<void *, DATA_T *> &layer_data_map) { … }
namespace vvl {
inline constexpr std::in_place_t in_place{ … };
template <typename T, typename Iterator>
class enumeration { … };
template <typename T, typename IndexType = size_t>
class IndexedIterator { … };
span;
template <typename T>
span<T> make_span(T *begin, size_t count) { … }
template <typename T>
span<T> make_span(T *begin, T *end) { … }
template <typename T, typename IndexType>
enumeration<T, IndexedIterator<T, IndexType>> enumerate(T *begin, IndexType count) { … }
template <typename T>
enumeration<T, IndexedIterator<T>> enumerate(T *begin, T *end) { … }
template <typename Container>
enumeration<typename Container::value_type, IndexedIterator<typename Container::value_type, typename Container::size_type>>
enumerate(Container &container) { … }
base_type;
struct TlsGuardPersist { … };
template <typename T>
class TlsGuard { … };
template <typename Container, typename Key = typename Container::key_type>
bool Contains(const Container &container, const Key &key) { … }
template <typename T>
bool Contains(const std::vector<T> &v, const T &value) { … }
template <typename Container, typename Key = typename Container::key_type, typename Value = typename Container::mapped_type>
Value *Find(Container &container, const Key &key) { … }
template <typename Container, typename Key = typename Container::key_type, typename Value = typename Container::mapped_type>
const Value *Find(const Container &container, const Key &key) { … }
template <typename Container, typename Predicate>
typename Container::size_type EraseIf(Container &c, Predicate &&p) { … }
template <typename T>
constexpr T MaxTypeValue([[maybe_unused]] T) { … }
template <typename T>
constexpr T MinTypeValue([[maybe_unused]] T) { … }
constexpr auto kU32Max = …;
constexpr auto kU64Max = …;
constexpr auto kI32Max = …;
constexpr auto kI64Max = …;
constexpr auto kNoIndex32 = …;
constexpr auto kNoIndex64 = …;
template <typename T>
T GetQuotientCeil(T numerator, T denominator) { … }
}