45#include <lal/detail/array.hpp>
104template <
typename value_t,
class indexer_t = value_t>
114 typename vt = value_t,
typename it = indexer_t,
115 std::enable_if_t< std::is_same_v<vt, it>,
bool > =
true
117 void init(
const std::size_t max_num_elems,
const std::size_t max_index_value)
noexcept
132 typename vt = value_t,
typename it = indexer_t,
133 std::enable_if_t< not std::is_same_v<vt, it>,
bool > =
true
136 const std::size_t max_num_elems,
137 const std::size_t max_index_value,
154 [[nodiscard]]
const value_t&
operator[] (
const std::size_t i)
const noexcept {
164 [[nodiscard]] std::size_t
size() const noexcept {
return m_size; }
167 [[nodiscard]]
bool exists(
const value_t& v)
const noexcept
171 [[nodiscard]] std::size_t
position(
const value_t& v)
const noexcept
175 void add(
const value_t& v)
noexcept {
176 const std::size_t idx_v =
index(v);
191 void add(value_t&& v)
noexcept {
192 const std::size_t idx_v =
index(v);
208 const std::size_t idx_v =
index(v);
275 [[nodiscard]] std::size_t
index(
const value_t& v)
const noexcept {
276 if constexpr (not std::is_same_v<value_t, indexer_t>) {
A set-like data structure implemented with an array.
Definition set_array.hpp:105
void add(value_t &&v) noexcept
Add a new element to the set.
Definition set_array.hpp:191
array< char > m_exists
Does a value exist in the set?
Definition set_array.hpp:265
value_t * begin_values() noexcept
Begin iterator to m_values.
Definition set_array.hpp:234
array< value_t > m_values
The unique values in this set.
Definition set_array.hpp:260
std::size_t position(const value_t &v) const noexcept
Where is an element located?
Definition set_array.hpp:171
void init(const std::size_t max_num_elems, const std::size_t max_index_value, indexer_t &&i) noexcept
Initialize the set with an indexer object.
Definition set_array.hpp:135
value_t * begin_position() noexcept
Begin iterator to m_position.
Definition set_array.hpp:243
array< std::size_t > m_position
The position of every value in the set.
Definition set_array.hpp:271
const value_t * begin_values() const noexcept
Begin iterator to m_values.
Definition set_array.hpp:232
void init(const std::size_t max_num_elems, const std::size_t max_index_value) noexcept
Initialize the set with no indexer object.
Definition set_array.hpp:117
value_t * end_values() noexcept
End iterator to m_values.
Definition set_array.hpp:238
const value_t * end_position() const noexcept
End iterator to m_position.
Definition set_array.hpp:245
std::size_t capacity() const noexcept
Maximum size of this set.
Definition set_array.hpp:162
const value_t & operator[](const std::size_t i) const noexcept
Operator to access values in a given position.
Definition set_array.hpp:154
bool exists(const value_t &v) const noexcept
Does an element exist?
Definition set_array.hpp:167
std::size_t m_size
The number of values in m_values.
Definition set_array.hpp:262
value_t * end_position() noexcept
End iterator to m_position.
Definition set_array.hpp:247
void remove(const value_t &v) noexcept
Remove an element from the set.
Definition set_array.hpp:207
void add(const value_t &v) noexcept
Add a new element to the set.
Definition set_array.hpp:175
static constexpr char EXISTS
Does an element exist in the set?
Definition set_array.hpp:251
indexer_t m_I
The indexer object.
Definition set_array.hpp:257
const value_t * end_values() const noexcept
End iterator to m_values.
Definition set_array.hpp:236
std::size_t index(const value_t &v) const noexcept
Calculate the index of an element using the indexer object m_I.
Definition set_array.hpp:275
const value_t * begin_position() const noexcept
Begin iterator to m_position.
Definition set_array.hpp:241
static constexpr char NOT_EXISTS
Does an element not exist in the set?
Definition set_array.hpp:253
std::size_t size() const noexcept
Actual size of this set.
Definition set_array.hpp:164
Main namespace of the library.
Definition basic_types.hpp:48
Wrapper of a C array for automatic deallocation of memory.
Definition array.hpp:59
T * begin() noexcept
Non-constant raw pointer to first element.
Definition array.hpp:300
T * end() noexcept
Non-constant raw pointer to last+1 element.
Definition array.hpp:302
std::size_t size() const noexcept
Size of the array.
Definition array.hpp:215
void resize(const std::size_t new_size) noexcept
Resize the array.
Definition array.hpp:187