ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
MaximumSegments.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*------------------------- File MaximumSegments.h -------------------------*/
3/*--------------------------------------------------------------------------*/
96/*--------------------------------------------------------------------------*/
97/*----------------------------- DEFINITIONS --------------------------------*/
98/*--------------------------------------------------------------------------*/
99
100#ifndef __ADS_MaximumSegments
101 #define __ADS_MaximumSegments
102/* self-identification: #endif constant */
103
104/*--------------------------------------------------------------------------*/
105/*------------------------------ INCLUDES ----------------------------------*/
106/*--------------------------------------------------------------------------*/
107
108#include "ADS/Contract.h"
109#include "ADS/Wide.h"
111
112#include <algorithm>
113#include <cstddef>
114#include <cstdint>
115#include <deque>
116#include <string>
117#include <type_traits>
118#include <vector>
119
120/*--------------------------------------------------------------------------*/
121/*--------------------------- NAMESPACE ------------------------------------*/
122/*--------------------------------------------------------------------------*/
123
124namespace ADS
125{
126
129template< class T >
131{
132 T sum{};
133 std::size_t first = 0;
134 std::size_t length = 0;
135 };
136
155template< class T >
156Segment< T > maxSumSegmentCubic( const std::vector< T > & D );
157
178template< class T >
179Segment< T > maxSumSegmentQuadratic( const std::vector< T > & D );
180
201template< class T >
202Segment< T > maxSumSegment( const std::vector< T > & D );
203
226template< class T >
227Segment< T > maxSumSegmentPrefix( const std::vector< T > & D );
228
256template< class T >
257Segment< T > maxSumSegmentLength( const std::vector< T > & D , std::size_t L ,
258 std::size_t U );
259
285template< class T >
286Segment< T > longestSegmentAtLeast( const std::vector< T > & D , T t );
287
303template< class T >
304Segment< T > longestSegmentAverageAtLeast( const std::vector< T > & D , T p ,
305 T q );
306
335template< class T >
336Segment< T > maxDensitySegment( const std::vector< T > & D , std::size_t L );
337
339[[nodiscard]] inline std::vector< int > gcIndicator( const std::string & dna );
340
341/*--------------------------------------------------------------------------*/
342
343} // end( namespace ADS )
344
345/*--------------------------------------------------------------------------*/
346/*-------------------------- IMPLEMENTATION --------------------------------*/
347/*--------------------------------------------------------------------------*/
348
349#include "ADS/algorithm/impl/MaximumSegments.tpp"
350
351/*--------------------------------------------------------------------------*/
352
353#endif /* MaximumSegments.h included */
354
355/*--------------------------------------------------------------------------*/
356/*----------------------- End File MaximumSegments.h -----------------------*/
357/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
Two problems on a sequence solved by the dynamic programming of chapter 13:
The arithmetic of two words that C++20 does not spell, in one form for every compiler: the product of...
Segment< T > longestSegmentAverageAtLeast(const std::vector< T > &D, T p, T q)
the longest segment of average at least , length 0 if none
Segment< T > maxSumSegmentPrefix(const std::vector< T > &D)
a nonempty segment of largest sum, by the minimum prefix sum,
std::vector< int > gcIndicator(const std::string &dna)
1 for the nucleotides C and G, in either case, and 0 for the others
Segment< T > longestSegmentAtLeast(const std::vector< T > &D, T t)
the longest segment of sum at least , length 0 if none,
Segment< T > maxSumSegmentLength(const std::vector< T > &D, std::size_t L, std::size_t U)
a segment of largest sum among those of length in ,
Segment< T > maxSumSegment(const std::vector< T > &D)
a nonempty segment of largest sum, by one scan,
Segment< T > maxDensitySegment(const std::vector< T > &D, std::size_t L)
a segment of largest average among those of length at least , its sum in the result,
Segment< T > maxSumSegmentCubic(const std::vector< T > &D)
a nonempty segment of largest sum, by all the pairs,
Segment< T > maxSumSegmentQuadratic(const std::vector< T > &D)
a nonempty segment of largest sum, by all the pairs,
Definition ADT.h:96
a segment of the array and its sum, with the place first and the length
Definition MaximumSegments.h:131
T sum
the sum of its items
Definition MaximumSegments.h:132
std::size_t first
the place of its first item
Definition MaximumSegments.h:133
std::size_t length
0 for no segment
Definition MaximumSegments.h:134