7#include "xstl/internal/map_interface.hpp"
22 using key_type = int32_t;
23 using mapped_type = T;
25 using size_type = std::size_t;
26 using iterator = value_type*;
27 using const_iterator =
const value_type*;
28 using key_container_type = std::vector<key_type>;
29 using mapped_container_type = std::vector<mapped_type>;
32 mapped_container_type values;
33 key_container_type keys;
34 key_container_type& keys_host;
36 explicit containers(size_type values_size, size_type keys_size)
37 : values(values_size), keys(keys_size + 1), keys_host{keys} {}
49 constexpr std::span<value_type> operator[](key_type key)
const {
50 const auto offset = keys[key];
51 const auto size = keys[key + 1] - offset;
52 return std::span<const value_type>(values + offset,
size);
55 constexpr std::span<value_type> operator[](key_type key) {
56 const auto offset = keys[key];
57 const auto size = keys[key + 1] - offset;
58 return std::span<value_type>(values + offset,
size);
67 : m_data(values, keys),
68 m_view{m_data.values.data(), m_data.keys.data()},
72#ifdef XSTL_BUILD_DOXYGEN
103 const_iterator
end()
const;
118 const_iterator
find(key_type key)
const;
124 size_type
count(key_type key)
const;
163 std::pair<const_iterator, const_iterator>
equal_range(key_type key)
const;
169 void fill(std::span<key_type> keys, std::span<mapped_type> values);
186 void fill_impl(std::span<key_type> keys, std::span<mapped_type> values);
193#include "xstl/cpu/detail/association_map.hpp"
bool contains(key_type key) const
Checks if the association map contains values associated to a specific key.
const_iterator lower_bound(key_type key) const
Returns a const iterator to the first element with a key not less than the specified key.
const_iterator begin() const
Returns a const iterator to the beginning of the values array.
const_iterator upper_bound(key_type key) const
Returns a const iterator to the first element with a key greater than the specified key.
View view()
Returns a view of the association map.
auto extents() const
Returns the extents of the containers in the association map.
const_iterator find(key_type key) const
Returns a const iterator to the first element with a specific key.
void fill(std::span< key_type > keys, std::span< mapped_type > values)
Fills the association map with keys and values from the provided spans.
iterator lower_bound(key_type key)
Returns an iterator to the first element with a key not less than the specified key.
auto empty() const
Checks if the association map is empty.
auto size() const
Returns the number of values in the association map.
const_iterator cbegin() const
Returns a const iterator to the beginning of the values array.
iterator end()
Returns an iterator to the end of the values array.
size_type count(key_type key) const
Returns the number of values with a specific key.
association_map(size_type values, size_type keys)
Constructs an association map with a specified number of values and keys.
Definition association_map.hpp:66
std::pair< iterator, iterator > equal_range(key_type key)
Returns a pair of iterators representing the range of values with a specific key.
const_iterator cend() const
Returns a const iterator to the end of the values array.
iterator upper_bound(key_type key)
Returns an iterator to the first element with a key greater than the specified key.
std::pair< const_iterator, const_iterator > equal_range(key_type key) const
Returns a pair of const iterators representing the range of values with a specific key.
iterator begin()
Returns an iterator to the beginning of the values array.
iterator find(key_type key)
Returns an iterator to the first element with a specific key.
Definition association_map.hpp:40
Definition association_map.hpp:45
Definition association_map.hpp:31