ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
SortedSearches.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*------------------------- File SortedSearches.h --------------------------*/
3/*--------------------------------------------------------------------------*/
68/*--------------------------------------------------------------------------*/
69/*----------------------------- DEFINITIONS --------------------------------*/
70/*--------------------------------------------------------------------------*/
71
72#ifndef __ADS_SortedSearches
73 #define __ADS_SortedSearches
74/* self-identification: #endif constant */
75
76/*--------------------------------------------------------------------------*/
77/*------------------------------ INCLUDES ----------------------------------*/
78/*--------------------------------------------------------------------------*/
79
80#include "ADS/Contract.h"
82#include "ADS/sort/Sorted.h"
83
84#include <algorithm>
85#include <cstddef>
86#include <functional>
87#include <iterator>
88#include <optional>
89#include <type_traits>
90#include <utility>
91#include <vector>
92
93/*--------------------------------------------------------------------------*/
94/*--------------------------- NAMESPACE ------------------------------------*/
95/*--------------------------------------------------------------------------*/
96
97namespace ADS
98{
99
122template< class T , class C = std::less<> >
123std::size_t rotatedMinimum( const std::vector< T > & A , C less = C() );
124
146template< class T >
147 requires( std::is_arithmetic_v< T > && ! std::is_same_v< T , bool > )
148std::size_t closestValue( const std::vector< T > & A , const T & x );
149
171template< class T , class S >
172std::optional< std::pair< std::size_t , std::size_t > >
173pairWithSum( const std::vector< T > & A , const S & x );
174
200template< class T , class C = std::less<> >
201T kthOfTwoSorted( const std::vector< T > & X , const std::vector< T > & Y ,
202 std::size_t k , C less = C() );
203
204/*--------------------------------------------------------------------------*/
205
206} // end( namespace ADS )
207
208/*--------------------------------------------------------------------------*/
209/*-------------------------- IMPLEMENTATION --------------------------------*/
210/*--------------------------------------------------------------------------*/
211
212#include "ADS/search/impl/SortedSearches.tpp"
213
214/*--------------------------------------------------------------------------*/
215
216#endif /* SortedSearches.h included */
217
218/*--------------------------------------------------------------------------*/
219/*----------------------- End File SortedSearches.h ------------------------*/
220/*--------------------------------------------------------------------------*/
The binary search of section 1.2 in a sorted vector : is compared with the middle item of the part ...
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...
std::size_t closestValue(const std::vector< T > &A, const T &x)
the first place of an item of the sorted at the least distance from , the smaller item on ties;
std::size_t rotatedMinimum(const std::vector< T > &A, C less=C())
the place of the minimum of , a strictly increasing vector rotated right by that number of places;
std::optional< std::pair< std::size_t, std::size_t > > pairWithSum(const std::vector< T > &A, const S &x)
two places of the sorted with , the sum computed in the type S, or nothing;
T kthOfTwoSorted(const std::vector< T > &X, const std::vector< T > &Y, std::size_t k, C less=C())
the item of rank , from 0, of the sorted and together;
Definition ADT.h:96