ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
SequenceQueries.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*------------------------- File SequenceQueries.h -------------------------*/
3/*--------------------------------------------------------------------------*/
63/*--------------------------------------------------------------------------*/
64/*----------------------------- DEFINITIONS --------------------------------*/
65/*--------------------------------------------------------------------------*/
66
67#ifndef __ADS_SequenceQueries
68 #define __ADS_SequenceQueries
69/* self-identification: #endif constant */
70
71/*--------------------------------------------------------------------------*/
72/*------------------------------ INCLUDES ----------------------------------*/
73/*--------------------------------------------------------------------------*/
74
75#include "ADS/Contract.h"
76#include "ADS/sort/MergeSort.h"
77#include "ADS/sort/Sorted.h"
78
79#include <algorithm>
80#include <cstddef>
81#include <functional>
82#include <map>
83#include <numeric>
84#include <optional>
85#include <ranges>
86#include <set>
87#include <type_traits>
88#include <utility>
89#include <vector>
90
91/*--------------------------------------------------------------------------*/
92/*--------------------------- NAMESPACE ------------------------------------*/
93/*--------------------------------------------------------------------------*/
94
95namespace ADS
96{
97
127template< class T , class C = std::less<> >
128std::vector< std::size_t > smallerToTheRight( const std::vector< T > & A ,
129 C less = C() );
130
154template< std::ranges::random_access_range R >
155std::pair< std::size_t , std::size_t > longestKDistinctRun( const R & S ,
156 std::size_t k );
157
179template< class T >
180 requires( std::is_arithmetic_v< T > && ! std::is_same_v< T , bool > )
181std::optional< std::pair< T , T > >
182largestGap( std::vector< std::pair< T , T > > I );
183
199template< class T , class W = T >
200 requires std::is_arithmetic_v< T >
201W lineAssignment( std::vector< T > H , std::vector< T > L );
202
203/*--------------------------------------------------------------------------*/
204
205} // end( namespace ADS )
206
207/*--------------------------------------------------------------------------*/
208/*-------------------------- IMPLEMENTATION --------------------------------*/
209/*--------------------------------------------------------------------------*/
210
211#include "ADS/algorithm/impl/SequenceQueries.tpp"
212
213/*--------------------------------------------------------------------------*/
214
215#endif /* SequenceQueries.h included */
216
217/*--------------------------------------------------------------------------*/
218/*----------------------- End File SequenceQueries.h -----------------------*/
219/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
Merge Sort (section 2.7.3): the two halves of the vector are sorted recursively and merged by mergePa...
The checks of the contracts of the sorts [see Contract.h]: a copy of the input kept only when the aud...
std::vector< std::size_t > smallerToTheRight(const std::vector< T > &A, C less=C())
the counts of the places with , by mergesort on the places;
W lineAssignment(std::vector< T > H, std::vector< T > L)
the least sum of over the permutations , computed in the type W, by sorting;
std::optional< std::pair< T, T > > largestGap(std::vector< std::pair< T, T > > I)
the longest stretch , between the first start and the last end, covered by none of the closed interva...
std::pair< std::size_t, std::size_t > longestKDistinctRun(const R &S, std::size_t k)
the start and the length of the first longest run of consecutive items of with at most distinct val...
Definition ADT.h:96