58#ifndef __ADS_BinarySearch
59 #define __ADS_BinarySearch
102template<
class T ,
class F >
103long binarySearch(
const std::vector< T > & A ,
const T & v , F && trace );
156template<
class T ,
class C = std::less<> >
157std::size_t
lowerBound(
const std::vector< T > & A ,
const T & v ,
158 std::size_t lo , std::size_t hi , C less = C() );
162template<
class T ,
class C = std::less<> >
163std::size_t
lowerBound(
const std::vector< T > & A ,
const T & v ,
185template<
class T ,
class C = std::less<> >
186std::size_t
upperBound(
const std::vector< T > & A ,
const T & v ,
212template<
class T ,
class C = std::less<> >
224#include "ADS/search/impl/BinarySearch.tpp"
The binary TREE of the book: an ordered tree where each node has at most two children,...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The checks of the contracts of the sorts [see Contract.h]: a copy of the input kept only when the aud...
a binary tree with pointers to the parent and to the two children
Definition BinaryTree.h:104
BinaryTree< T > * decisionTree(const std::vector< T > &A)
the decision tree of binarySearch() on , nil if is empty; the caller owns it
long binarySearch(const std::vector< T > &A, const T &v, F &&trace)
the place of in the sorted , or -1; trace( i , j , m ) on each call that examines
std::size_t upperBound(const std::vector< T > &A, const T &v, C less=C())
the first place of an item larger than , if none
std::size_t gallopSearch(const std::vector< T > &A, const T &v, C less=C())
the first place of an item not smaller than , found by looking at the places and then by a binary s...
std::size_t lowerBound(const std::vector< T > &A, const T &v, std::size_t lo, std::size_t hi, C less=C())
the first place in of an item not smaller than , if none