Namespace Ase::Aux
Namespace List > Ase > Aux
Auxillary algorithms brodly useful.
Public Types
Type | Name |
---|---|
typedef decltype(std::declval< T >() - std::declval< T >()) | callable_minus |
typedef decltype(std::declval< T & >().reserve(int(0))) | callable_reserve_int |
Public Functions
Type | Name |
---|---|
RandIter | binary_lookup (RandIter begin, RandIter end, Cmp cmp_elements, const Arg & arg) |
std::pair< RandIter, bool > | binary_lookup_fuzzy (RandIter begin, RandIter end, Cmp cmp_elements, const Arg & arg) |
std::pair< RandIter, bool > | binary_lookup_insertion_pos (RandIter begin, RandIter end, Cmp cmp_elements, const Arg & arg) |
RandIter | binary_lookup_sibling (RandIter begin, RandIter end, Cmp cmp_elements, const Arg & arg) |
Container | container_copy (const Iteratable & source) Create a Container with copies of the elements ofsource . |
bool | contains (const C & container, const std::function< bool(typename C::value_type const &value)> & pred) Returns true if container element for whichpred() is true. |
size_t | erase_all (C & container, const std::function< bool(typename C::value_type const &value)> & pred) Erase all elements for which pred() is true in vector or list. |
size_t | erase_first (C & container, const std::function< bool(typename C::value_type const &value)> & pred) Erase first element for which pred() is true in vector or list. |
ssize_t | index_of (const IterableContainer & c, const std::function< bool(const typename IterableContainer::value_type &e)> & match) |
std::vector< T >::iterator | insert_sorted (std::vector< T > & vec, const T & value, Compare compare) Insert value into sortedvec usingbinary_lookup_insertion_pos() withcompare . |
Public Static Functions
Type | Name |
---|---|
int | compare_greater (const Value & v1, const Value & v2) Comparison function useful to sort greater items first. |
int | compare_lesser (const Value & v1, const Value & v2) Comparison function useful to sort lesser items first. |
Public Types Documentation
typedef callable_minus
using Ase::Aux::callable_minus = typedef decltype (std::declval<T>() - std::declval<T>());
typedef callable_reserve_int
using Ase::Aux::callable_reserve_int = typedef decltype (std::declval<T&>().reserve (int (0)));
Public Functions Documentation
function binary_lookup
template<typename RandIter, class Cmp, typename Arg>
inline RandIter Ase::Aux::binary_lookup (
RandIter begin,
RandIter end,
Cmp cmp_elements,
const Arg & arg
)
Perform binary lookup and yield exact match or end. The arguments [ begin, end [ denote the range used for the lookup, arg is passed along with the current element to the cmp_elements function.
function binary_lookup_fuzzy
template<typename RandIter, class Cmp, typename Arg, int case_lookup_or_sibling_or_insertion>
inline std::pair< RandIter, bool > Ase::Aux::binary_lookup_fuzzy (
RandIter begin,
RandIter end,
Cmp cmp_elements,
const Arg & arg
)
function binary_lookup_insertion_pos
template<typename RandIter, class Cmp, typename Arg>
inline std::pair< RandIter, bool > Ase::Aux::binary_lookup_insertion_pos (
RandIter begin,
RandIter end,
Cmp cmp_elements,
const Arg & arg
)
Perform a binary lookup to find the insertion position for a new element. Return (end,false) for end-begin==0, or return (position,true) for exact match, otherwise return (position,false) where position indicates the location for the key to be inserted (and may equal end).
function binary_lookup_sibling
template<typename RandIter, class Cmp, typename Arg>
inline RandIter Ase::Aux::binary_lookup_sibling (
RandIter begin,
RandIter end,
Cmp cmp_elements,
const Arg & arg
)
Perform a binary lookup to yield exact or nearest match. return end for end-begin==0, otherwise return the exact match element, or, if there's no such element, return the element last visited, which is pretty close to an exact match (will be one off into either direction).
function container_copy
template<class Container, class Iteratable>
Container Ase::Aux::container_copy (
const Iteratable & source
)
function contains
template<typename C>
inline bool Ase::Aux::contains (
const C & container,
const std::function< bool(typename C::value_type const &value)> & pred
)
function erase_all
template<class C>
inline size_t Ase::Aux::erase_all (
C & container,
const std::function< bool(typename C::value_type const &value)> & pred
)
function erase_first
template<class C>
inline size_t Ase::Aux::erase_first (
C & container,
const std::function< bool(typename C::value_type const &value)> & pred
)
function index_of
template<class IterableContainer>
ssize_t Ase::Aux::index_of (
const IterableContainer & c,
const std::function< bool(const typename IterableContainer::value_type &e)> & match
)
function insert_sorted
template<class T, class Compare>
inline std::vector< T >::iterator Ase::Aux::insert_sorted (
std::vector< T > & vec,
const T & value,
Compare compare
)
Public Static Functions Documentation
function compare_greater
template<typename Value>
static inline int Ase::Aux::compare_greater (
const Value & v1,
const Value & v2
)
function compare_lesser
template<typename Value>
static inline int Ase::Aux::compare_lesser (
const Value & v1,
const Value & v2
)
The documentation for this class was generated from the following file /__w/anklang/anklang/ase/utils.hh