|
template<typename RandIter , class Cmp , typename Arg > |
RandIter | binary_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 > |
RandIter | binary_lookup_sibling (RandIter begin, RandIter end, Cmp cmp_elements, const Arg &arg) |
|
template<class Container , class Iteratable > |
Container | container_copy (const Iteratable &source) |
|
template<typename C > |
bool | contains (const C &container, const std::function< bool(typename C::value_type const &value)> &pred) |
|
template<class C > |
size_t | erase_all (C &container, const std::function< bool(typename C::value_type const &value)> &pred) |
|
template<class C > |
size_t | erase_first (C &container, const std::function< bool(typename C::value_type const &value)> &pred) |
|
template<class IterableContainer > |
ssize_t | index_of (const IterableContainer &c, const std::function< bool(const typename IterableContainer::value_type &e)> &match) |
|
template<class T , class Compare > |
std::vector< T >::iterator | insert_sorted (std::vector< T > &vec, const T &value, Compare compare) |
|
Auxillary algorithms brodly useful.
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).
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).
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.