Helios Engine 0.1.0
A modular ECS based data-oriented C++23 game engine
 
Loading...
Searching...
No Matches
helios::container Namespace Reference

Classes

class  BasicStaticString
 A fixed-capacity string class that owns its storage. More...
 
class  SparseSet
 A sparse set data structure for efficient mapping of sparse indices to dense storage of values. More...
 

Typedefs

template<size_t N>
using StaticString = BasicStaticString< N, char >
 Fixed-capacity string of char.
 
template<size_t N>
using StaticWString = BasicStaticString< N, wchar_t >
 Fixed-capacity string of wchar_t.
 
template<size_t N>
using StaticU8String = BasicStaticString< N, char8_t >
 Fixed-capacity string of char8_t.
 
template<size_t N>
using StaticU16String = BasicStaticString< N, char16_t >
 Fixed-capacity string of char16_t.
 
template<size_t N>
using StaticU32String = BasicStaticString< N, char32_t >
 Fixed-capacity string of char32_t.
 

Functions

template<typename T , typename IndexType , typename Allocator >
void swap (SparseSet< T, IndexType, Allocator > &lhs, SparseSet< T, IndexType, Allocator > &rhs) noexcept
 Swaps two sparse sets.
 
template<size_t N1, size_t N2, typename CharT , typename Traits >
constexpr auto operator+ (const BasicStaticString< N1, CharT, Traits > &lhs, const BasicStaticString< N2, CharT, Traits > &rhs) noexcept -> BasicStaticString< N1+N2, CharT, Traits >
 Concatenates two StaticStrings.
 
template<size_t N, typename CharT , typename Traits >
constexpr auto operator+ (const BasicStaticString< N, CharT, Traits > &lhs, std::basic_string_view< CharT, Traits > rhs) noexcept -> BasicStaticString< N, CharT, Traits >
 Concatenates StaticString with string_view.
 
template<size_t N, typename CharT , typename Traits >
constexpr auto operator+ (std::basic_string_view< CharT, Traits > lhs, const BasicStaticString< N, CharT, Traits > &rhs) noexcept -> BasicStaticString< N, CharT, Traits >
 Concatenates string_view with StaticString.
 
template<size_t N, typename CharT , typename Traits >
constexpr auto operator+ (const BasicStaticString< N, CharT, Traits > &lhs, CharT rhs) noexcept -> BasicStaticString< N, CharT, Traits >
 Concatenates StaticString with character.
 
template<size_t N, typename CharT , typename Traits >
constexpr auto operator+ (CharT lhs, const BasicStaticString< N, CharT, Traits > &rhs) noexcept -> BasicStaticString< N, CharT, Traits >
 Concatenates character with StaticString.
 
template<size_t StrCapacity, typename CharT , typename Traits >
constexpr void swap (BasicStaticString< StrCapacity, CharT, Traits > &lhs, BasicStaticString< StrCapacity, CharT, Traits > &rhs) noexcept
 Swaps two BasicStaticStrings.
 
template<size_t StrCapacity, typename CharT , typename Traits >
constexpr auto erase (BasicStaticString< StrCapacity, CharT, Traits > &str, CharT value) noexcept -> typename BasicStaticString< StrCapacity, CharT, Traits >::size_type
 Erases all elements equal to value.
 
template<size_t StrCapacity, typename CharT , typename Traits , typename Pred >
constexpr auto erase_if (BasicStaticString< StrCapacity, CharT, Traits > &str, Pred pred) noexcept -> typename BasicStaticString< StrCapacity, CharT, Traits >::size_type
 Erases all elements satisfying predicate.
 
template<size_t StrCapacity, typename CharT , typename Traits >
auto operator<< (std::basic_ostream< CharT, Traits > &os, const BasicStaticString< StrCapacity, CharT, Traits > &str) -> std::basic_ostream< CharT, Traits > &
 Outputs a BasicStaticString to an output stream.
 
template<size_t StrCapacity, typename CharT , typename Traits >
auto operator>> (std::basic_istream< CharT, Traits > &is, BasicStaticString< StrCapacity, CharT, Traits > &str) -> std::basic_istream< CharT, Traits > &
 Inputs a BasicStaticString from an input stream.
 

Typedef Documentation

◆ StaticString

template<size_t N>
using helios::container::StaticString = typedef BasicStaticString<N, char>

Fixed-capacity string of char.

Template Parameters
NMaximum capacity

Definition at line 1414 of file static_string.hpp.

◆ StaticU16String

template<size_t N>
using helios::container::StaticU16String = typedef BasicStaticString<N, char16_t>

Fixed-capacity string of char16_t.

Template Parameters
NMaximum capacity

Definition at line 1435 of file static_string.hpp.

◆ StaticU32String

template<size_t N>
using helios::container::StaticU32String = typedef BasicStaticString<N, char32_t>

Fixed-capacity string of char32_t.

Template Parameters
NMaximum capacity

Definition at line 1442 of file static_string.hpp.

◆ StaticU8String

template<size_t N>
using helios::container::StaticU8String = typedef BasicStaticString<N, char8_t>

Fixed-capacity string of char8_t.

Template Parameters
NMaximum capacity

Definition at line 1428 of file static_string.hpp.

◆ StaticWString

template<size_t N>
using helios::container::StaticWString = typedef BasicStaticString<N, wchar_t>

Fixed-capacity string of wchar_t.

Template Parameters
NMaximum capacity

Definition at line 1421 of file static_string.hpp.

Function Documentation

◆ erase()

template<size_t StrCapacity, typename CharT , typename Traits >
constexpr auto helios::container::erase ( BasicStaticString< StrCapacity, CharT, Traits > &  str,
CharT  value 
) -> typename BasicStaticString<StrCapacity, CharT, Traits>::size_type
constexprnoexcept

Erases all elements equal to value.

Template Parameters
StrCapacityStrCapacity of the string
CharTCharacter type
TraitsCharacter traits
Parameters
strString to modify
valueValue to erase
Returns
Number of elements erased

Definition at line 1562 of file static_string.hpp.

1563 {
1564 const auto original_size = str.Size();
1565 auto* new_end = std::remove(str.begin(), str.end(), value);
1566 str.Resize(static_cast<typename BasicStaticString<StrCapacity, CharT, Traits>::size_type>(new_end - str.begin()));
1567 return original_size - str.Size();
1568}
constexpr void Resize(size_type count, CharT ch=CharT{}) noexcept
Resizes the string.
constexpr size_type Size() const noexcept
Returns the number of characters.
constexpr iterator begin() noexcept
constexpr iterator end() noexcept

◆ erase_if()

template<size_t StrCapacity, typename CharT , typename Traits , typename Pred >
constexpr auto helios::container::erase_if ( BasicStaticString< StrCapacity, CharT, Traits > &  str,
Pred  pred 
) -> typename BasicStaticString<StrCapacity, CharT, Traits>::size_type
constexprnoexcept

Erases all elements satisfying predicate.

Template Parameters
StrCapacityStrCapacity of the string
CharTCharacter type
TraitsCharacter traits
PredPredicate type
Parameters
strString to modify
predUnary predicate
Returns
Number of elements erased

Definition at line 1581 of file static_string.hpp.

1582 {
1583 const auto original_size = str.Size();
1584 auto* new_end = std::remove_if(str.begin(), str.end(), pred);
1585 str.Resize(static_cast<typename BasicStaticString<StrCapacity, CharT, Traits>::size_type>(new_end - str.begin()));
1586 return original_size - str.Size();
1587}

◆ operator+() [1/5]

template<size_t N, typename CharT , typename Traits >
constexpr auto helios::container::operator+ ( CharT  lhs,
const BasicStaticString< N, CharT, Traits > &  rhs 
) -> BasicStaticString<N, CharT, Traits>
constexprnoexcept

Concatenates character with StaticString.

Warning
Triggers assertion if rhs.Size() >= N.
Template Parameters
NStrCapacity of the static string
CharTCharacter type
TraitsCharacter traits
Parameters
lhsCharacter
rhsStatic string
Returns
Concatenated string (same capacity as rhs)

Definition at line 1531 of file static_string.hpp.

1532 {
1534 result.Append(rhs.View());
1535 return result;
1536}
A fixed-capacity string class that owns its storage.
constexpr std::basic_string_view< CharT, Traits > View() const noexcept
Returns a string_view of the content.

◆ operator+() [2/5]

template<size_t N, typename CharT , typename Traits >
constexpr auto helios::container::operator+ ( const BasicStaticString< N, CharT, Traits > &  lhs,
CharT  rhs 
) -> BasicStaticString<N, CharT, Traits>
constexprnoexcept

Concatenates StaticString with character.

Warning
Triggers assertion if lhs.Size() >= N.
Template Parameters
NStrCapacity of the static string
CharTCharacter type
TraitsCharacter traits
Parameters
lhsStatic string
rhsCharacter
Returns
Concatenated string (same capacity as lhs)

Definition at line 1513 of file static_string.hpp.

1514 {
1516 result.PushBack(rhs);
1517 return result;
1518}
constexpr void PushBack(CharT ch) noexcept
Appends a character.

◆ operator+() [3/5]

template<size_t N, typename CharT , typename Traits >
constexpr auto helios::container::operator+ ( const BasicStaticString< N, CharT, Traits > &  lhs,
std::basic_string_view< CharT, Traits >  rhs 
) -> BasicStaticString<N, CharT, Traits>
constexprnoexcept

Concatenates StaticString with string_view.

Warning
Triggers assertion if combined length > N.
Template Parameters
NStrCapacity of the static string
CharTCharacter type
TraitsCharacter traits
Parameters
lhsStatic string
rhsString view
Returns
Concatenated string (same capacity as lhs)

Definition at line 1475 of file static_string.hpp.

1477 {
1479 result.Append(rhs);
1480 return result;
1481}
constexpr BasicStaticString & Append(std::basic_string_view< CharT, Traits > sv) noexcept
Appends a string_view.

◆ operator+() [4/5]

template<size_t N1, size_t N2, typename CharT , typename Traits >
constexpr auto helios::container::operator+ ( const BasicStaticString< N1, CharT, Traits > &  lhs,
const BasicStaticString< N2, CharT, Traits > &  rhs 
) -> BasicStaticString<N1 + N2, CharT, Traits>
constexprnoexcept

Concatenates two StaticStrings.

Template Parameters
N1StrCapacity of first string
N2StrCapacity of second string
CharTCharacter type
TraitsCharacter traits
Parameters
lhsFirst string
rhsSecond string
Returns
Concatenated string with capacity N1 + N2

Definition at line 1455 of file static_string.hpp.

1457 {
1459 result.Append(lhs.View());
1460 result.Append(rhs.View());
1461 return result;
1462}

◆ operator+() [5/5]

template<size_t N, typename CharT , typename Traits >
constexpr auto helios::container::operator+ ( std::basic_string_view< CharT, Traits >  lhs,
const BasicStaticString< N, CharT, Traits > &  rhs 
) -> BasicStaticString<N, CharT, Traits>
constexprnoexcept

Concatenates string_view with StaticString.

Warning
Triggers assertion if combined length > N.
Template Parameters
NStrCapacity of the static string
CharTCharacter type
TraitsCharacter traits
Parameters
lhsString view
rhsStatic string
Returns
Concatenated string (same capacity as rhs)

Definition at line 1494 of file static_string.hpp.

1496 {
1498 result.Append(rhs.View());
1499 return result;
1500}

◆ operator<<()

template<size_t StrCapacity, typename CharT , typename Traits >
auto helios::container::operator<< ( std::basic_ostream< CharT, Traits > &  os,
const BasicStaticString< StrCapacity, CharT, Traits > &  str 
) -> std::basic_ostream<CharT, Traits>&
inline

Outputs a BasicStaticString to an output stream.

Template Parameters
StrCapacityStrCapacity of the string
CharTCharacter type
TraitsCharacter traits
Parameters
osOutput stream
strString to output
Returns
Reference to the output stream

Definition at line 1599 of file static_string.hpp.

1600 {
1601 return os << str.View();
1602}

◆ operator>>()

template<size_t StrCapacity, typename CharT , typename Traits >
auto helios::container::operator>> ( std::basic_istream< CharT, Traits > &  is,
BasicStaticString< StrCapacity, CharT, Traits > &  str 
) -> std::basic_istream<CharT, Traits>&
inline

Inputs a BasicStaticString from an input stream.

Template Parameters
StrCapacityStrCapacity of the string
CharTCharacter type
TraitsCharacter traits
Parameters
isInput stream
strString to input
Returns
Reference to the input stream

Definition at line 1614 of file static_string.hpp.

1615 {
1616 std::basic_string<CharT, Traits> temp;
1617 is >> temp;
1618 if (temp.size() <= StrCapacity) {
1619 str.Assign(temp);
1620 } else {
1621 is.setstate(std::ios_base::failbit);
1622 }
1623 return is;
1624}
constexpr BasicStaticString & Assign(std::basic_string_view< CharT, Traits > sv) noexcept
Assigns a string_view.

◆ swap() [1/2]

template<size_t StrCapacity, typename CharT , typename Traits >
constexpr void helios::container::swap ( BasicStaticString< StrCapacity, CharT, Traits > &  lhs,
BasicStaticString< StrCapacity, CharT, Traits > &  rhs 
)
constexprnoexcept

Swaps two BasicStaticStrings.

Template Parameters
StrCapacityStrCapacity of the strings
CharTCharacter type
TraitsCharacter traits
Parameters
lhsFirst string
rhsSecond string

Definition at line 1547 of file static_string.hpp.

1548 {
1549 lhs.Swap(rhs);
1550}
constexpr void Swap(BasicStaticString &other) noexcept
Swaps contents with another BasicStaticString.

◆ swap() [2/2]

template<typename T , typename IndexType , typename Allocator >
void helios::container::swap ( SparseSet< T, IndexType, Allocator > &  lhs,
SparseSet< T, IndexType, Allocator > &  rhs 
)
noexcept

Swaps two sparse sets.

Non-member swap function for efficient swapping of sparse sets. Time complexity: O(1). Exception safety: No-throw guarantee.

Template Parameters
TType of values stored
IndexTypeType used for indices
AllocatorAllocator type
Parameters
lhsFirst sparse set
rhsSecond sparse set

Definition at line 698 of file sparse_set.hpp.

698 {
699 lhs.Swap(rhs);
700}
void Swap(SparseSet &other) noexcept
Swaps the contents of this sparse set with another.