ADS
Algorithms and Data Structures
Toggle main menu visibility
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
"
81
#include "
ADS/search/BinarySearch.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
97
namespace
ADS
98
{
99
122
template
<
class
T ,
class
C = std::less<> >
123
std::size_t
rotatedMinimum
(
const
std::vector< T > & A , C less = C() );
124
146
template
<
class
T >
147
requires
( std::is_arithmetic_v< T > && ! std::is_same_v< T , bool > )
148
std::size_t
closestValue
(
const
std::vector< T > & A ,
const
T & x );
149
171
template
<
class
T ,
class
S >
172
std::optional< std::pair< std::size_t , std::size_t > >
173
pairWithSum
(
const
std::vector< T > & A ,
const
S & x );
174
200
template
<
class
T ,
class
C = std::less<> >
201
T
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
/*--------------------------------------------------------------------------*/
BinarySearch.h
The binary search of section 1.2 in a sorted vector : is compared with the middle item of the part ...
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
Sorted.h
The checks of the contracts of the sorts [see Contract.h]: a copy of the input kept only when the aud...
ADS::closestValue
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;
ADS::rotatedMinimum
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;
ADS::pairWithSum
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;
ADS::kthOfTwoSorted
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;
ADS
Definition
ADT.h:96
ADS
search
SortedSearches.h
Generated by
1.17.0