ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
Minimum.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*----------------------------- File Minimum.h -----------------------------*/
3/*--------------------------------------------------------------------------*/
35/*--------------------------------------------------------------------------*/
36/*----------------------------- DEFINITIONS --------------------------------*/
37/*--------------------------------------------------------------------------*/
38
39#ifndef __ADS_Minimum
40 #define __ADS_Minimum
41/* self-identification: #endif constant */
42
43/*--------------------------------------------------------------------------*/
44/*------------------------------ INCLUDES ----------------------------------*/
45/*--------------------------------------------------------------------------*/
46
47#include "ADS/Contract.h"
48#include "ADS/sort/Sorted.h"
49
50#include <algorithm>
51#include <cstddef>
52#include <functional>
53#include <ranges>
54#include <type_traits>
55#include <utility>
56#include <vector>
57
58/*--------------------------------------------------------------------------*/
59/*--------------------------- NAMESPACE ------------------------------------*/
60/*--------------------------------------------------------------------------*/
61
62namespace ADS
63{
64
84template< class T , class C = std::less<> >
85std::size_t argmin( const std::vector< T > & A , std::size_t start ,
86 std::size_t end , C less = C() );
87
91template< std::ranges::random_access_range R , class C = std::less<> >
92 requires( ! std::is_same_v< std::remove_cvref_t< R > ,
93 std::vector< std::ranges::range_value_t< R > > > )
94std::size_t argmin( const R & A , std::size_t start , std::size_t end ,
95 C less = C() );
96
107template< class T , class C = std::less<> >
108const T & min( const std::vector< T > & A , C less = C() );
109
138template< class T , class C = std::less<> >
139std::pair< T , T > minMax( const std::vector< T > & A , C less = C() );
140
163template< class T , class C = std::less<> >
164std::pair< T , T > minMaxDivide( const std::vector< T > & A , C less = C() );
165
166/*--------------------------------------------------------------------------*/
167
168} // end( namespace ADS )
169
170/*--------------------------------------------------------------------------*/
171/*-------------------------- IMPLEMENTATION --------------------------------*/
172/*--------------------------------------------------------------------------*/
173
174#include "ADS/search/impl/Minimum.tpp"
175
176/*--------------------------------------------------------------------------*/
177
178#endif /* Minimum.h included */
179
180/*--------------------------------------------------------------------------*/
181/*--------------------------- End File Minimum.h ---------------------------*/
182/*--------------------------------------------------------------------------*/
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...
const T & min(const std::vector< T > &A, C less=C())
the minimum of a vector that is not empty, comparisons
std::pair< T, T > minMaxDivide(const std::vector< T > &A, C less=C())
the pair of minMax() by divide et impera: the halves solved recursively and their minima and maxima c...
std::size_t argmin(const std::vector< T > &A, std::size_t start, std::size_t end, C less=C())
the place of the first minimum of the range
std::pair< T, T > minMax(const std::vector< T > &A, C less=C())
the minimum and the maximum together, by pairs: the two items of a pair are compared,...
Definition ADT.h:96