template <typename Traits, typename Allocator = soagen:: allocator>
table class
A table.
Template parameters | |
---|---|
Traits | The soagen:: |
Allocator | The allocator used by the table. |
Effectively a multi-column std::
Public types
- using allocator_type = Allocator
- The allocator used by the table.
-
template <auto Column>using column_traits =
/* ... */
- Returns the soagen::
column_traits for the column at the specified index. -
template <auto Column>using column_type =
/* ... */
- Returns the
value_type
for the column at the specified index. -
using const_iterator = soagen::
const_iterator_type<table> - Row iterators returned by const-qualified iterator functions.
-
using const_row_type = soagen::
const_row_type<table> - Const row type used by tables.
-
using const_span_type = soagen::
const_span_type<table> - Const-qualified span type.
-
using difference_type = std::
ptrdiff_t - The signed integer difference type used by tables.
-
using iterator = soagen::
iterator_type<table> - Row iterators returned by iterator functions.
-
using row_type = soagen::
row_type<table> - Regular (lvalue-qualified) row type used by tables.
-
using rvalue_iterator = soagen::
rvalue_iterator_type<table> - Row iterators returned by rvalue-qualified iterator functions.
-
using rvalue_row_type = soagen::
rvalue_row_type<table> - Rvalue row type used by tables.
-
using rvalue_span_type = soagen::
rvalue_span_type<table> - Rvalue-qualified span type.
-
using size_type = std::
size_t - The unsigned integer size type used by tables.4.
-
using span_type = soagen::
span_type<table> - Regular (lvalue-qualified) span type.
- using table_traits = Traits
- The soagen::
table_traits for the table.
Public static variables
-
static size_
t aligned_stride constexpr - The number of rows to advance to maintain the requested
alignment
for every column. -
static size_
type column_count constexpr - The number of columns in the table.
Constructors, destructors, conversion operators
- table() defaulted
- Default constructor.
- table(table&&) defaulted
- Move constructor.
- table(const table&) defaulted
- Copy constructor.
-
table(const allocator_
type& alloc) explicit constexpr noexcept - Constructs with the given allocator.
-
table(allocator_
type&& alloc) explicit constexpr noexcept - Constructs with the given allocator.
- ~table() defaulted
- Destructor.
Public functions
-
auto get_allocator() const → allocator_
type constexpr noexcept - Returns the allocator being used by the table.
- auto operator=(table&&) → table& defaulted
- Move-assignment operator.
- auto operator=(const table&) → table& defaulted
- Copy-assignment operator.
Adding rows
-
template <typename... Args>void emplace(size_
type index, Args && ... args) noexcept(…) - Constructs a new row in-place at an arbitrary position in the table.
-
template <typename... Args>void emplace_back(Args && ... args) noexcept(…)
- Constructs a new row in-place at the end of the table.
Capacity
-
auto allocation_size() const → size_
t constexpr noexcept - Returns the size of the current underlying buffer allocation in bytes.
-
auto capacity() const → size_
type constexpr noexcept - Returns the number of rows that can be held in currently allocated storage.
- auto empty() const → bool constexpr noexcept
- Returns true if the number of rows is zero.
-
auto max_size() const → size_
type constexpr noexcept - Returns the maximum possible number of rows.
-
void reserve(size_
type new_cap) noexcept(…) - Reserves storage for (at least) the given number of rows.
- void shrink_to_fit() noexcept(…)
- Frees unused capacity.
-
auto size() const → size_
type constexpr noexcept - Returns the current number of rows.
Columns
-
template <auto Column>auto column() → column_
type<Column>* constexpr noexcept - Returns a pointer to the elements of a specific column.
-
template <auto Column>auto column() const → std::
add_const_t<column_ type<Column>>* constexpr noexcept - Returns a const-qualified pointer to the elements of a specific column.
-
auto data() → std::
byte* constexpr noexcept - Returns a pointer to the raw byte backing array.
-
auto data() const → conststd::
byte* constexpr noexcept - Returns a const pointer to the raw byte backing array.
-
template <typename Func>void for_each_column(Func&& func) constexpr noexcept(…)
- Invokes a function once for each column data pointer.
-
template <typename Func>void for_each_column(Func&& func) const constexpr noexcept(…)
- Invokes a function once for each column data pointer (const overload).
Comparison
- auto operator<(const table& lhs, const table& rhs) → bool constexpr noexcept(…)
- Returns true if the LHS table is ordered lexicographically less-than the RHS table.
- auto operator<=(const table& lhs, const table& rhs) → bool constexpr noexcept(…)
- Returns true if the LHS table is ordered lexicographically less-than-or-equal-to the RHS table.
- auto operator>(const table& lhs, const table& rhs) → bool constexpr noexcept(…)
- Returns true if the LHS table is ordered lexicographically greater-than the RHS table.
- auto operator>=(const table& lhs, const table& rhs) → bool constexpr noexcept(…)
- Returns true if the LHS table is ordered lexicographically greater-than-or-equal-to the RHS table.
Equality
- auto operator!=(const table& lhs, const table& rhs) → bool constexpr noexcept(…)
- Returns true if not all of the elements in two tables are equal.
- auto operator==(const table& lhs, const table& rhs) → bool constexpr noexcept(…)
- Returns true if all of the elements in two tables are equal.
Iterators
-
template <auto... Cols>auto begin() & → soagen::
iterator_type<table, Cols...> constexpr noexcept - Returns an iterator to the first row in the table.
-
template <auto... Cols>auto begin() && → soagen::
rvalue_iterator_type<table, Cols...> constexpr noexcept - Returns an iterator to the first row in the table.
-
template <auto... Cols>auto begin() const & → soagen::
const_iterator_type<table, Cols...> constexpr noexcept - Returns an iterator to the first row in the table.
-
template <auto... Cols>auto cbegin() const → soagen::
const_iterator_type<table, Cols...> constexpr noexcept - Returns an iterator to the first row in the table.
-
template <auto... Cols>auto cend() const → soagen::
const_iterator_type<table, Cols...> constexpr noexcept - Returns an iterator to one-past-the-last row in the table.
-
template <auto... Cols>auto end() & → soagen::
iterator_type<table, Cols...> constexpr noexcept - Returns an iterator to one-past-the-last row in the table.
-
template <auto... Cols>auto end() && → soagen::
rvalue_iterator_type<table, Cols...> constexpr noexcept - Returns an iterator to one-past-the-last row in the table.
-
template <auto... Cols>auto end() const & → soagen::
const_iterator_type<table, Cols...> constexpr noexcept - Returns an iterator to one-past-the-last row in the table.
Modifiers
- void clear() noexcept
- Removes all rows from table.
-
void erase(size_
type pos) noexcept(…) - Erases the row at the given index.
-
void pop_back(size_
type num = 1) noexcept(…) - Removes the last row(s) from the table.
-
void resize(size_
type new_size) noexcept(…) - Resizes the table to the given number of rows.
- void swap(table& other) constexpr noexcept(…)
- Swaps the contents of the table with another.
-
template <auto A, auto B>void swap_columns() noexcept(…)
- Swaps two columns.
-
auto unordered_erase(size_
type pos) → soagen:: optional<size_ type> noexcept(…) - Erases the row at the given index without preserving order.
Rows
-
template <auto... Cols>auto at(size_
type index) & → soagen:: row_type<table, Cols...> - Returns the row at the given index.
-
template <auto... Cols>auto at(size_
type index) && → soagen:: rvalue_row_type<table, Cols...> - Returns the row at the given index (rvalue overload).
-
template <auto... Cols>auto at(size_
type index) const & → soagen:: const_row_type<table, Cols...> - Returns the row at the given index (const overload).
-
template <auto... Cols>auto back() & → soagen::
row_type<table, Cols...> noexcept - Returns the very last row in the table.
-
template <auto... Cols>auto back() && → soagen::row_row_type<table, Cols...> noexcept
- Returns the very last row in the table (rvalue overload).
-
template <auto... Cols>auto back() const & → soagen::
const_row_type<table, Cols...> noexcept - Returns the very last row in the table (const overload).
-
template <auto... Cols>auto front() & → soagen::
row_type<table, Cols...> noexcept - Returns the very first row in the table.
-
template <auto... Cols>auto front() && → soagen::
rvalue_row_type<table, Cols...> noexcept - Returns the very first row in the table (rvalue overload).
-
template <auto... Cols>auto front() const & → soagen::
const_row_type<table, Cols...> noexcept - Returns the very first row in the table (const overload).
-
auto operator[](size_
type index) & → row_ type noexcept - Returns the row at the given index.
-
auto operator[](size_
type index) && → rvalue_ row_ type noexcept - Returns the row at the given index (rvalue overload).
-
auto operator[](size_
type index) const & → const_ row_ type noexcept - Returns the row at the given index (const overload).
-
template <auto... Cols>auto row(size_
type index) & → soagen:: row_type<table, Cols...> noexcept - Returns the row at the given index.
-
template <auto... Cols>auto row(size_
type index) && → soagen:: rvalue_row_type<table, Cols...> noexcept - Returns the row at the given index.
-
template <auto... Cols>auto row(size_
type index) const & → soagen:: const_row_type<table, Cols...> noexcept - Returns the row at the given index.
Spans
-
auto const_subspan(size_
type start, size_ type count = static_cast<size_ type>(-1)) const → const_ span_ type noexcept - Returns a const-qualified span of (some part of) the table.
-
auto subspan(size_
type start, size_ type count = static_cast<size_ type>(-1)) & → span_ type noexcept - Returns a span of (some part of) the table.
-
auto subspan(size_
type start, size_ type count = static_cast<size_ type>(-1)) && → rvalue_ span_ type noexcept - Returns an rvalue-qualified span of (some part of) the table.
-
auto subspan(size_
type start, size_ type count = static_cast<size_ type>(-1)) const & → const_ span_ type noexcept - Returns a const-qualified span of (some part of) the table.
Function documentation
template <typename Traits, typename Allocator>
size_ t soagen::table::allocation_size() const constexpr noexcept
Returns the size of the current underlying buffer allocation in bytes.
void soagen::table::for_each_column(Func&& func) constexpr noexcept(…)
Invokes a function once for each column data pointer.
Template parameters | |
---|---|
Func | A callable type compatible with one of the following signatures:
Overload resolution is performed in the order listed above. |
Parameters | |
func | The callable to invoke. |
void soagen::table::for_each_column(Func&& func) const constexpr noexcept(…)
Invokes a function once for each column data pointer (const overload).
Template parameters | |
---|---|
Func | A callable type compatible with one of the following signatures:
Overload resolution is performed in the order listed above. |
Parameters | |
func | The callable to invoke. |
void soagen::table::swap_columns() noexcept(…)
Swaps two columns.
template <typename Traits, typename Allocator>
soagen:: optional<size_ type> soagen::table::unordered_erase(size_ type pos) noexcept(…)
Erases the row at the given index without preserving order.
Returns | The index of the row that was moved into the erased row's position, if any. |
---|
This is much faster than erase() because it uses the swap-and-pop idiom: Instead of shifting all the higher rows downward, the last row is moved into the position of the erased one and the size of the table is reduced by 1.
soagen:: row_type<table, Cols...> soagen::table::at(size_ type index) &
Returns the row at the given index.
Template parameters | |
---|---|
Cols | Indices of the columns to include in the row. Leave the list empty for all columns. |
Exceptions | |
std:: |
soagen:: rvalue_row_type<table, Cols...> soagen::table::at(size_ type index) &&
Returns the row at the given index (rvalue overload).
Template parameters | |
---|---|
Cols | Indices of the columns to include in the row. Leave the list empty for all columns. |
Exceptions | |
std:: |
soagen:: const_row_type<table, Cols...> soagen::table::at(size_ type index) const &
Returns the row at the given index (const overload).
Template parameters | |
---|---|
Cols | Indices of the columns to include in the row. Leave the list empty for all columns. |
Exceptions | |
std:: |
soagen:: row_type<table, Cols...> soagen::table::back() & noexcept
Returns the very last row in the table.
Template parameters | |
---|---|
Cols | Indices of the columns to include in the row. Leave the list empty for all columns. |
soagen:: const_row_type<table, Cols...> soagen::table::back() const & noexcept
Returns the very last row in the table (const overload).
Template parameters | |
---|---|
Cols | Indices of the columns to include in the row. Leave the list empty for all columns. |
soagen:: row_type<table, Cols...> soagen::table::front() & noexcept
Returns the very first row in the table.
Template parameters | |
---|---|
Cols | Indices of the columns to include in the row. Leave the list empty for all columns. |
soagen:: rvalue_row_type<table, Cols...> soagen::table::front() && noexcept
Returns the very first row in the table (rvalue overload).
Template parameters | |
---|---|
Cols | Indices of the columns to include in the row. Leave the list empty for all columns. |
soagen:: const_row_type<table, Cols...> soagen::table::front() const & noexcept
Returns the very first row in the table (const overload).
Template parameters | |
---|---|
Cols | Indices of the columns to include in the row. Leave the list empty for all columns. |
soagen:: row_type<table, Cols...> soagen::table::row(size_ type index) & noexcept
Returns the row at the given index.
Template parameters | |
---|---|
Cols | Indices of the columns to include in the row. Leave the list empty for all columns. |
soagen:: rvalue_row_type<table, Cols...> soagen::table::row(size_ type index) && noexcept
Returns the row at the given index.
Template parameters | |
---|---|
Cols | Indices of the columns to include in the row. Leave the list empty for all columns. |
soagen:: const_row_type<table, Cols...> soagen::table::row(size_ type index) const & noexcept
Returns the row at the given index.
Template parameters | |
---|---|
Cols | Indices of the columns to include in the row. Leave the list empty for all columns. |
Variable documentation
template <typename Traits, typename Allocator>
static size_ t soagen::table::aligned_stride constexpr
The number of rows to advance to maintain the requested alignment
for every column.
The stride size you need to use when iterating through rows of this table such that the starting element for each batch in each column would have the same memory alignment as the value specified for the column-specific alignment
.