Anklang C++ API 0.0.0
Loading...
Searching...
No Matches
Ase::Aux Namespace Reference

Typedefs

template<typename T >
usingcallable_minus = decltype(std::declval< T >() - std::declval< T >())
template<typename T >
usingcallable_reserve_int = decltype(std::declval< T & >().reserve(int(0)))

Functions

template<typename RandIter , class Cmp , typename Arg >
RandIterbinary_lookup (RandIter begin, RandIter end, Cmp cmp_elements, const Arg &arg)
template<typename RandIter , class Cmp , typename Arg , int case_lookup_or_sibling_or_insertion>
std::pair< RandIter, bool >binary_lookup_fuzzy (RandIter begin, RandIter end, Cmp cmp_elements, const Arg &arg)
template<typename RandIter , class Cmp , typename Arg >
std::pair< RandIter, bool >binary_lookup_insertion_pos (RandIter begin, RandIter end, Cmp cmp_elements, const Arg &arg)
template<typename RandIter , class Cmp , typename Arg >
RandIterbinary_lookup_sibling (RandIter begin, RandIter end, Cmp cmp_elements, const Arg &arg)
template<class Container , class Iteratable >
Containercontainer_copy (const Iteratable &source)
template<typename C >
boolcontains (const C &container, const std::function< bool(typename C::value_type const &value)> &pred)
template<class C >
size_terase_all (C &container, const std::function< bool(typename C::value_type const &value)> &pred)
template<class C >
size_terase_first (C &container, const std::function< bool(typename C::value_type const &value)> &pred)
template<class IterableContainer >
ssize_tindex_of (const IterableContainer &c, const std::function< bool(const typename IterableContainer::value_type &e)> &match)
template<class T , class Compare >
std::vector< T >::iteratorinsert_sorted (std::vector< T > &vec, const T &value, Compare compare)

Detailed Description

Auxillary algorithms brodly useful.

Typedef Documentation

callable_reserve_int

template<typename T >
using callable_reserve_int = decltype (std::declval<T&>().reserve (int (0)))

callable_minus

template<typename T >
using callable_minus = decltype (std::declval<T>() - std::declval<T>())

Function Documentation

container_copy()

template<class Container , class Iteratable >
Container container_copy ( const Iteratable & source)

Create a `Container` with copies of the elements of `source`.

binary_lookup_fuzzy()

template<typename RandIter , class Cmp , typename Arg , int case_lookup_or_sibling_or_insertion>
std::pair< RandIter, bool > binary_lookup_fuzzy ( RandIter begin,
RandIter end,
Cmp cmp_elements,
const Arg & arg
)
extern

binary_lookup_insertion_pos()

template<typename RandIter , class Cmp , typename Arg >
std::pair< RandIter, bool > binary_lookup_insertion_pos ( RandIter begin,
RandIter end,
Cmp cmp_elements,
const Arg & arg
)
extern

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).

binary_lookup_sibling()

template<typename RandIter , class Cmp , typename Arg >
RandIter binary_lookup_sibling ( RandIter begin,
RandIter end,
Cmp cmp_elements,
const Arg & arg
)
extern

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).

binary_lookup()

template<typename RandIter , class Cmp , typename Arg >
RandIter binary_lookup ( RandIter begin,
RandIter end,
Cmp cmp_elements,
const Arg & arg
)
extern

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.

erase_first()

template<class C >
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.

erase_all()

template<class C >
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.

contains()

template<typename C >
bool contains ( const C & container,
const std::function< bool(typename C::value_type const &value)> & pred
)

Returns `true` if container element for which `pred()` is true.

insert_sorted()

template<class T , class Compare >
std::vector< T >::iterator insert_sorted ( std::vector< T > & vec,
const T & value,
Compare compare
)

Insert `value` into sorted `vec` using binary_lookup_insertion_pos() with `compare`.

index_of()

template<class IterableContainer >
ssize_t index_of ( const IterableContainer & c,
const std::function< bool(const typename IterableContainer::value_type &e)> & match
)