ADS
Algorithms and Data Structures
Toggle main menu visibility
Loading...
Searching...
No Matches
LongestCommonSubsequence.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/*-------------------- File LongestCommonSubsequence.h ---------------------*/
3
/*--------------------------------------------------------------------------*/
43
/*--------------------------------------------------------------------------*/
44
/*----------------------------- DEFINITIONS --------------------------------*/
45
/*--------------------------------------------------------------------------*/
46
47
#ifndef __ADS_LongestCommonSubsequence
48
#define __ADS_LongestCommonSubsequence
49
/* self-identification: #endif constant */
50
51
/*--------------------------------------------------------------------------*/
52
/*------------------------------ INCLUDES ----------------------------------*/
53
/*--------------------------------------------------------------------------*/
54
55
#include "
ADS/Contract.h
"
56
57
#include <algorithm>
58
#include <cstddef>
59
#include <string>
60
#include <tuple>
61
#include <utility>
62
#include <vector>
63
64
/*--------------------------------------------------------------------------*/
65
/*--------------------------- NAMESPACE ------------------------------------*/
66
/*--------------------------------------------------------------------------*/
67
68
namespace
ADS
69
{
70
92
template
<
class
S >
93
std::vector< std::vector< int > >
lcsTable
(
const
S & P ,
const
S & T );
94
115
template
<
class
S >
116
int
lcsMemo
(
const
S & P ,
const
S & T ,
long
* solved =
nullptr
);
117
139
template
<
class
S >
140
S
lcs
(
const
S & P ,
const
S & T );
141
169
template
<
class
S >
170
std::vector< std::pair< char , typename S::value_type > >
diff
(
const
S & P ,
171
const
S & T );
172
196
template
<
class
S >
197
std::tuple< std::size_t , std::size_t , std::size_t >
198
longestCommonSubstring
(
const
S & P ,
const
S & T );
199
200
/*--------------------------------------------------------------------------*/
201
202
}
// end( namespace ADS )
203
204
/*--------------------------------------------------------------------------*/
205
/*-------------------------- IMPLEMENTATION --------------------------------*/
206
/*--------------------------------------------------------------------------*/
207
208
#include "ADS/string/impl/LongestCommonSubsequence.tpp"
209
210
/*--------------------------------------------------------------------------*/
211
212
#endif
/* LongestCommonSubsequence.h included */
213
214
/*--------------------------------------------------------------------------*/
215
/*------------------ End File LongestCommonSubsequence.h -------------------*/
216
/*--------------------------------------------------------------------------*/
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
ADS::diff
std::vector< std::pair< char, typename S::value_type > > diff(const S &P, const S &T)
the differences from to : ( '-' , p ) for an item of only, ( '+' , t ) for an item of only,...
ADS::longestCommonSubstring
std::tuple< std::size_t, std::size_t, std::size_t > longestCommonSubstring(const S &P, const S &T)
the longest common substring: its length and where it ends in and , the first one found by rows of ;...
ADS::lcsTable
std::vector< std::vector< int > > lcsTable(const S &P, const S &T)
the table of the lengths of the LCS of the prefixes of and
ADS::lcsMemo
int lcsMemo(const S &P, const S &T, long *solved=nullptr)
the length of the LCS by the memoization of the book, marking the subproblems not solved yet; the nu...
ADS::lcs
S lcs(const S &P, const S &T)
a longest common subsequence, read back from the table
ADS
Definition
ADT.h:96
ADS
string
LongestCommonSubsequence.h
Generated by
1.17.0