MT Core (C++)
Core library for replacing C++ standard in project usage
|
A Slice which is just a pointer + length Accessing elements through the array operator will do bounds checks Accessing out of bounds will terminate the program instead of throw Can also get sub slices. More...
#include <slice.hpp>
Public Types | |
using | Elem = T |
Public Member Functions | |
decltype(auto) | ptr_iter () noexcept |
decltype(auto) | ptr_iter () const noexcept |
decltype(auto) | iter () const noexcept |
constexpr Slice< std::add_const_t< T > > | to_const () const noexcept |
Converts to a const Slice. | |
constexpr void | init (T *head, size_t len) |
Initializes a Slice Using init instead of a constructor so that slices allocated with malloc or an arena can be initialized after the fact. | |
constexpr const T & | operator[] (size_t i) const noexcept |
Access element at a specific index Const operator, returns a const reference. | |
T & | operator[] (size_t i) noexcept |
Access element at a specific index Non-const operator, returns a mutable reference. | |
T & | at (size_t i) noexcept |
Access element at a specific index Non-const operator, returns a mutable reference. | |
constexpr const T & | at (size_t i) const noexcept |
Access element at a specific index Const operator, returns a const reference. | |
constexpr size_t | size () const noexcept |
Gets the size of a Slice. | |
constexpr bool | empty () const noexcept |
Checks if a Slice is empty. | |
constexpr Slice | sub_rng (size_t start, size_t end) const noexcept |
Gets a sub slice from start to end index. | |
constexpr Slice | sub (size_t start) const noexcept |
Gets a sub Slice from start. | |
constexpr Slice | sub (size_t start, size_t len) const noexcept |
Gets a sub Slice from start up to a length. | |
std::strong_ordering | operator<=> (const Slice< std::remove_const_t< T > > &other) const noexcept |
Compares against another Slice. | |
std::strong_ordering | operator<=> (const Slice< std::add_const_t< T > > &other) const noexcept |
Compares against another Slice. | |
bool | operator== (const Slice< std::remove_const_t< T > > &o) const noexcept |
bool | operator!= (const Slice< std::remove_const_t< T > > &o) const noexcept |
bool | operator< (const Slice< std::remove_const_t< T > > &o) const noexcept |
bool | operator> (const Slice< std::remove_const_t< T > > &o) const noexcept |
bool | operator<= (const Slice< std::remove_const_t< T > > &o) const noexcept |
bool | operator>= (const Slice< std::remove_const_t< T > > &o) const noexcept |
bool | operator== (const Slice< std::add_const_t< T > > &o) const noexcept |
bool | operator!= (const Slice< std::add_const_t< T > > &o) const noexcept |
bool | operator< (const Slice< std::add_const_t< T > > &o) const noexcept |
bool | operator> (const Slice< std::add_const_t< T > > &o) const noexcept |
bool | operator<= (const Slice< std::add_const_t< T > > &o) const noexcept |
bool | operator>= (const Slice< std::add_const_t< T > > &o) const noexcept |
Public Attributes | |
T * | head = nullptr |
size_t | len = 0 |
A Slice which is just a pointer + length Accessing elements through the array operator will do bounds checks Accessing out of bounds will terminate the program instead of throw Can also get sub slices.
Accessing elements is \(O(1)\) Getting a sub-slice is \(O(1)\) Cannot remove/add arbitrary elements
T | Type of element pointed to by the Slice |
Definition at line 46 of file colls/slice.hpp.
using mtcore::Slice< T >::Elem = T |
Definition at line 47 of file colls/slice.hpp.
|
inlinenodiscardconstexprnoexcept |
Access element at a specific index Const operator, returns a const reference.
i | Index of the element in the Slice to access |
Definition at line 108 of file colls/slice.hpp.
|
inlinenodiscardnoexcept |
Access element at a specific index Non-const operator, returns a mutable reference.
i | Index of the element in the Slice to access |
Definition at line 101 of file colls/slice.hpp.
|
inlinenodiscardconstexprnoexcept |
Checks if a Slice is empty.
Definition at line 118 of file colls/slice.hpp.
|
inlineconstexpr |
Initializes a Slice Using init instead of a constructor so that slices allocated with malloc or an arena can be initialized after the fact.
Definition at line 69 of file colls/slice.hpp.
|
inlinenodiscardnoexcept |
Definition at line 54 of file colls/slice.hpp.
|
inlinenoexcept |
Definition at line 240 of file colls/slice.hpp.
|
inlinenoexcept |
Definition at line 214 of file colls/slice.hpp.
|
inlinenoexcept |
Definition at line 244 of file colls/slice.hpp.
|
inlinenoexcept |
Definition at line 218 of file colls/slice.hpp.
|
inlinenoexcept |
Definition at line 252 of file colls/slice.hpp.
|
inlinenoexcept |
Definition at line 226 of file colls/slice.hpp.
|
inlinenoexcept |
Compares against another Slice.
other | Constant Slice to compare to |
Definition at line 177 of file colls/slice.hpp.
|
inlinenoexcept |
Compares against another Slice.
other | Mutable Slice to compare to |
Definition at line 168 of file colls/slice.hpp.
|
inlinenoexcept |
Definition at line 236 of file colls/slice.hpp.
|
inlinenoexcept |
Definition at line 210 of file colls/slice.hpp.
|
inlinenoexcept |
Definition at line 248 of file colls/slice.hpp.
|
inlinenoexcept |
Definition at line 222 of file colls/slice.hpp.
|
inlinenoexcept |
Definition at line 257 of file colls/slice.hpp.
|
inlinenoexcept |
Definition at line 231 of file colls/slice.hpp.
|
inlinenodiscardconstexprnoexcept |
Access element at a specific index Const operator, returns a const reference.
i | Index of the element in the Slice to access |
Definition at line 79 of file colls/slice.hpp.
|
inlinenoexcept |
Access element at a specific index Non-const operator, returns a mutable reference.
i | Index of the element in the Slice to access |
Definition at line 90 of file colls/slice.hpp.
|
inlinenodiscardnoexcept |
Definition at line 53 of file colls/slice.hpp.
|
inlinenodiscardnoexcept |
Definition at line 52 of file colls/slice.hpp.
|
inlinenodiscardconstexprnoexcept |
Gets the size of a Slice.
Definition at line 113 of file colls/slice.hpp.
|
inlinenodiscardconstexprnoexcept |
Gets a sub Slice from start.
start | The starting index to get a sub Slice from |
Definition at line 138 of file colls/slice.hpp.
|
inlinenodiscardconstexprnoexcept |
Gets a sub Slice from start up to a length.
Definition at line 156 of file colls/slice.hpp.
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
Converts to a const Slice.
Definition at line 57 of file colls/slice.hpp.
T* mtcore::Slice< T >::head = nullptr |
Definition at line 49 of file colls/slice.hpp.
size_t mtcore::Slice< T >::len = 0 |
Definition at line 50 of file colls/slice.hpp.