TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
contains the definition of the function longest_common_string_length More...
#include <cassert>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
Go to the source code of this file.
Classes | |
struct | TestCase |
represents single example inputs and expected output of the function longest_common_string_length More... | |
Functions | |
std::size_t | longest_common_string_length (const std::string &string_a, const std::string &string_b) |
computes the length of the longest common string created from input strings | |
std::vector< TestCase > | get_test_cases () |
template<typename TestCases > | |
static void | test_longest_common_string_length (const TestCases &test_cases) |
checks the function longest_common_string_length agains example data | |
template<typename TestCases > | |
static void | test_longest_common_string_length_is_symmetric (const TestCases &test_cases) |
checks if the function longest_common_string_length returns the same result when its argument are flipped | |
std::string | reverse_str (const std::string &in_str) |
reverses a given string | |
template<typename TestCases > | |
static void | test_longest_common_string_length_for_reversed_inputs (const TestCases &test_cases) |
checks if the function longest_common_string_length returns the same result when its inputs are reversed | |
static void | tests () |
runs all tests for longest_common_string_length funcion | |
int | main () |
Main function. | |
contains the definition of the function longest_common_string_length
the function longest_common_string_length computes the length of the longest common string which can be created of two input strings by removing characters from them
Definition in file longest_common_string.cpp.
std::vector< TestCase > get_test_cases | ( | ) |
Definition at line 69 of file longest_common_string.cpp.
std::size_t longest_common_string_length | ( | const std::string & | string_a, |
const std::string & | string_b ) |
computes the length of the longest common string created from input strings
for assert for std::cout for std::string for std::move for std::vector
has O(str_a.size()*str_b.size()) time and memory complexity
string_a | first input string |
string_b | second input string |
Definition at line 28 of file longest_common_string.cpp.
int main | ( | void | ) |
Main function.
Definition at line 156 of file longest_common_string.cpp.
std::string reverse_str | ( | const std::string & | in_str | ) |
reverses a given string
in_str | input string |
Definition at line 119 of file longest_common_string.cpp.
|
static |
checks the function longest_common_string_length agains example data
test_cases | list of test cases |
type | representing a list of test cases |
Definition at line 91 of file longest_common_string.cpp.
|
static |
checks if the function longest_common_string_length returns the same result when its inputs are reversed
test_cases | list of test cases |
type | representing a list of test cases |
Definition at line 130 of file longest_common_string.cpp.
|
static |
checks if the function longest_common_string_length returns the same result when its argument are flipped
test_cases | list of test cases |
type | representing a list of test cases |
Definition at line 105 of file longest_common_string.cpp.
|
static |
runs all tests for longest_common_string_length funcion
Definition at line 142 of file longest_common_string.cpp.