ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
MonotoneSearch.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*------------------------- File MonotoneSearch.h --------------------------*/
3/*--------------------------------------------------------------------------*/
56/*--------------------------------------------------------------------------*/
57/*----------------------------- DEFINITIONS --------------------------------*/
58/*--------------------------------------------------------------------------*/
59
60#ifndef __ADS_MonotoneSearch
61 #define __ADS_MonotoneSearch
62/* self-identification: #endif constant */
63
64/*--------------------------------------------------------------------------*/
65/*------------------------------ INCLUDES ----------------------------------*/
66/*--------------------------------------------------------------------------*/
67
68#include "ADS/Contract.h"
69#include "ADS/sort/Sorted.h"
70
71#include <concepts>
72#include <cstddef>
73#include <limits>
74#include <type_traits>
75
76/*--------------------------------------------------------------------------*/
77/*--------------------------- NAMESPACE ------------------------------------*/
78/*--------------------------------------------------------------------------*/
79
80namespace ADS
81{
82
108template< std::integral I , class P >
109I exponentialSearch( P && p , I lo = I( 0 ) );
110
128template< class G , class P >
129std::size_t unboundedSearch( G && get , P && pred );
130
151template< std::unsigned_integral U >
152U integerSqrt( U n );
153
156template< std::unsigned_integral U >
157bool isPerfectSquare( U n );
158
159/*--------------------------------------------------------------------------*/
160
161} // end( namespace ADS )
162
163/*--------------------------------------------------------------------------*/
164/*-------------------------- IMPLEMENTATION --------------------------------*/
165/*--------------------------------------------------------------------------*/
166
167#include "ADS/search/impl/MonotoneSearch.tpp"
168
169/*--------------------------------------------------------------------------*/
170
171#endif /* MonotoneSearch.h included */
172
173/*--------------------------------------------------------------------------*/
174/*----------------------- End File MonotoneSearch.h ------------------------*/
175/*--------------------------------------------------------------------------*/
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...
bool isPerfectSquare(U n)
true if for an integer , i.e., if the square of integerSqrt( n ) is
std::size_t unboundedSearch(G &&get, P &&pred)
the first place where get( i ), which gives an optional item, empty past the end of the sequence,...
U integerSqrt(U n)
the largest with , by a binary search with no overflow; steps for bits, none for a bool,...
I exponentialSearch(P &&p, I lo=I(0))
the least with , false and then true from ; evaluations of
Definition ADT.h:96