TrinityCore
Trinity::Containers Namespace Reference

Namespaces

namespace  Impl
 
namespace  Lists
 

Classes

class  FlatSet
 

Concepts

concept  Map
 

Functions

template<Map M>
auto MapGetValuePtr (M &map, typename M::key_type const &key)
 
template<Map M>
void MultimapErasePair (M &multimap, typename M::key_type const &key, typename M::mapped_type const &value)
 
template<std::ranges::forward_range C>
void RandomResize (C &container, std::size_t requestedSize)
 
template<std::ranges::forward_range C, invocable_r< bool, std::ranges::range_reference_t< C > > Predicate>
void RandomResize (C &container, Predicate &&predicate, std::size_t requestedSize)
 
template<std::ranges::input_range C>
auto SelectRandomContainerElement (C const &container) -> std::add_const_t< decltype(*std::ranges::begin(container))> &
 
template<std::ranges::input_range C>
auto SelectRandomWeightedContainerElement (C const &container, std::span< double > const &weights) -> decltype(std::ranges::begin(container))
 
template<std::ranges::input_range C, invocable_r< double, std::ranges::range_reference_t< C > > Fn>
auto SelectRandomWeightedContainerElement (C const &container, Fn weightExtractor) -> decltype(std::ranges::begin(container))
 
template<std::random_access_iterator Iterator>
void RandomShuffle (Iterator begin, Iterator end)
 Reorder the elements of the iterator range randomly. More...
 
template<std::ranges::random_access_range C>
void RandomShuffle (C &container)
 Reorder the elements of the container randomly. More...
 
template<std::input_iterator Iterator1, std::sentinel_for< Iterator1 > Sentinel1, std::input_iterator Iterator2, std::sentinel_for< Iterator2 > Sentinel2>
constexpr bool Intersects (Iterator1 first1, Sentinel1 last1, Iterator2 first2, Sentinel2 last2)
 
template<std::input_iterator Iterator1, std::sentinel_for< Iterator1 > Sentinel1, std::input_iterator Iterator2, std::sentinel_for< Iterator2 > Sentinel2, invocable_r< bool, std::iter_reference_t< Iterator1 >, std::iter_reference_t< Iterator2 > > Predicate>
constexpr bool Intersects (Iterator1 first1, Sentinel1 last1, Iterator2 first2, Sentinel2 last2, Predicate &&equalPred)
 
template<std::ranges::forward_range Container, invocable_r< bool, std::ranges::range_reference_t< Container > > Predicate>
requires requires { c.erase(c.begin(), c.end()); }
constexpr void EraseIf (Container &c, Predicate p)
 
template<typename T >
constexpr decltype(auto) EnsureWritableVectorIndex (std::vector< T > &vec, typename std::vector< T >::size_type i)
 
template<typename T >
constexpr decltype(auto) EnsureWritableVectorIndex (std::vector< T > &vec, typename std::vector< T >::size_type i, T const &resizeDefault)
 
template<typename Container , typename NeedleContainer , typename ContainsOperator = bool(std::string const&, std::string const&), typename T = void>
auto FuzzyFindIn (Container const &container, NeedleContainer const &needles, ContainsOperator const &contains=StringContainsStringI, int(*bonus)(decltype((*std::begin(std::declval< Container >()))))=nullptr)
 
template<typename iterator , class end_iterator = iterator>
constexpr IteratorPair< iterator, end_iterator > MakeIteratorPair (iterator first, end_iterator second)
 
template<typename iterator , class end_iterator = iterator>
constexpr IteratorPair< iterator, end_iterator > MakeIteratorPair (std::pair< iterator, end_iterator > iterators)
 
template<class M >
auto MapEqualRange (M &map, typename M::key_type const &key)
 

Variables

constexpr auto MapKey = []<typename Pair>(Pair&& pair) constexpr -> decltype(auto) { return (std::forward<Pair>(pair).first); }
 
constexpr auto MapValue
 

Function Documentation

◆ EnsureWritableVectorIndex() [1/2]

template<typename T >
constexpr decltype(auto) Trinity::Containers::EnsureWritableVectorIndex ( std::vector< T > &  vec,
typename std::vector< T >::size_type  i 
)
inlineconstexpr

Returns a mutable reference to element at index i Will resize vector if neccessary to ensure element at i can be safely written

This exists as separate overload instead of one function with default argument to allow using with vectors of non-default-constructible classes

Definition at line 299 of file Containers.h.

+ Here is the caller graph for this function:

◆ EnsureWritableVectorIndex() [2/2]

template<typename T >
constexpr decltype(auto) Trinity::Containers::EnsureWritableVectorIndex ( std::vector< T > &  vec,
typename std::vector< T >::size_type  i,
T const &  resizeDefault 
)
inlineconstexpr

Returns a mutable reference to element at index i Will resize vector if neccessary to ensure element at i can be safely written

This overload allows specifying what value to pad vector with during .resize

Definition at line 314 of file Containers.h.

◆ EraseIf()

template<std::ranges::forward_range Container, invocable_r< bool, std::ranges::range_reference_t< Container > > Predicate>
requires requires { c.erase(c.begin(), c.end()); }
constexpr void Trinity::Containers::EraseIf ( Container &  c,
Predicate  p 
)
inlineconstexpr

Definition at line 283 of file Containers.h.

+ Here is the caller graph for this function:

◆ FuzzyFindIn()

template<typename Container , typename NeedleContainer , typename ContainsOperator = bool(std::string const&, std::string const&), typename T = void>
auto Trinity::Containers::FuzzyFindIn ( Container const &  container,
NeedleContainer const &  needles,
ContainsOperator const &  contains = StringContainsStringI,
int(*)(decltype((*std::begin(std::declval< Container >()))))  bonus = nullptr 
)

Definition at line 30 of file FuzzyFind.h.

◆ Intersects() [1/2]

template<std::input_iterator Iterator1, std::sentinel_for< Iterator1 > Sentinel1, std::input_iterator Iterator2, std::sentinel_for< Iterator2 > Sentinel2>
constexpr bool Trinity::Containers::Intersects ( Iterator1  first1,
Sentinel1  last1,
Iterator2  first2,
Sentinel2  last2 
)
inlineconstexpr

Definition at line 203 of file Containers.h.

+ Here is the caller graph for this function:

◆ Intersects() [2/2]

template<std::input_iterator Iterator1, std::sentinel_for< Iterator1 > Sentinel1, std::input_iterator Iterator2, std::sentinel_for< Iterator2 > Sentinel2, invocable_r< bool, std::iter_reference_t< Iterator1 >, std::iter_reference_t< Iterator2 > > Predicate>
constexpr bool Trinity::Containers::Intersects ( Iterator1  first1,
Sentinel1  last1,
Iterator2  first2,
Sentinel2  last2,
Predicate &&  equalPred 
)
inlineconstexpr

Definition at line 234 of file Containers.h.

◆ MakeIteratorPair() [1/2]

template<typename iterator , class end_iterator = iterator>
constexpr IteratorPair< iterator, end_iterator > Trinity::Containers::MakeIteratorPair ( iterator  first,
end_iterator  second 
)
constexpr

Definition at line 48 of file IteratorPair.h.

+ Here is the caller graph for this function:

◆ MakeIteratorPair() [2/2]

template<typename iterator , class end_iterator = iterator>
constexpr IteratorPair< iterator, end_iterator > Trinity::Containers::MakeIteratorPair ( std::pair< iterator, end_iterator >  iterators)
constexpr

Definition at line 54 of file IteratorPair.h.

◆ MapEqualRange()

template<class M >
auto Trinity::Containers::MapEqualRange ( M &  map,
typename M::key_type const &  key 
)

Definition at line 60 of file IteratorPair.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MapGetValuePtr()

template<Map M>
auto Trinity::Containers::MapGetValuePtr ( M &  map,
typename M::key_type const &  key 
)
inline

Returns a pointer to mapped value (or the value itself if map stores pointers)

Definition at line 37 of file MapUtils.h.

◆ MultimapErasePair()

template<Map M>
void Trinity::Containers::MultimapErasePair ( M &  multimap,
typename M::key_type const &  key,
typename M::mapped_type const &  value 
)

Definition at line 57 of file MapUtils.h.

+ Here is the caller graph for this function:

◆ RandomResize() [1/2]

template<std::ranges::forward_range C, invocable_r< bool, std::ranges::range_reference_t< C > > Predicate>
void Trinity::Containers::RandomResize ( C &  container,
Predicate &&  predicate,
std::size_t  requestedSize 
)

First use predicate filter

Definition at line 92 of file Containers.h.

+ Here is the call graph for this function:

◆ RandomResize() [2/2]

template<std::ranges::forward_range C>
void Trinity::Containers::RandomResize ( C &  container,
std::size_t  requestedSize 
)

Definition at line 67 of file Containers.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RandomShuffle() [1/2]

template<std::ranges::random_access_range C>
void Trinity::Containers::RandomShuffle ( C &  container)
inline

Reorder the elements of the container randomly.

Parameters
containerContainer to reorder

Definition at line 184 of file Containers.h.

+ Here is the call graph for this function:

◆ RandomShuffle() [2/2]

template<std::random_access_iterator Iterator>
void Trinity::Containers::RandomShuffle ( Iterator  begin,
Iterator  end 
)
inline

Reorder the elements of the iterator range randomly.

Parameters
beginBeginning of the range to reorder
endEnd of the range to reorder

Definition at line 171 of file Containers.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SelectRandomContainerElement()

template<std::ranges::input_range C>
auto Trinity::Containers::SelectRandomContainerElement ( C const &  container) -> std::add_const_t<decltype(*std::ranges::begin(container))>&
inline

Definition at line 110 of file Containers.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SelectRandomWeightedContainerElement() [1/2]

template<std::ranges::input_range C, invocable_r< double, std::ranges::range_reference_t< C > > Fn>
auto Trinity::Containers::SelectRandomWeightedContainerElement ( C const &  container,
Fn  weightExtractor 
) -> decltype(std::ranges::begin(container))
inline

Definition at line 143 of file Containers.h.

+ Here is the call graph for this function:

◆ SelectRandomWeightedContainerElement() [2/2]

template<std::ranges::input_range C>
auto Trinity::Containers::SelectRandomWeightedContainerElement ( C const &  container,
std::span< double > const &  weights 
) -> decltype(std::ranges::begin(container))
inline

Definition at line 127 of file Containers.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ MapKey

constexpr auto Trinity::Containers::MapKey = []<typename Pair>(Pair&& pair) constexpr -> decltype(auto) { return (std::forward<Pair>(pair).first); }
inlineconstexpr

Map key projection for various std::ranges algorithms

Definition at line 72 of file MapUtils.h.

◆ MapValue

constexpr auto Trinity::Containers::MapValue
inlineconstexpr
Initial value:
= []<typename Pair>(Pair&& pair) constexpr -> decltype(auto) { return (std::forward<Pair>(pair).second);
}

Map value projection for various std::ranges algorithms

Definition at line 77 of file MapUtils.h.