|
ADS
Algorithms and Data Structures
|
The number of ways of writing a sequence \( X \) of \( n \) items as a concatenation of words, the counting version of the word break problem [see WordBreak.h, which finds one of them]. More...
#include "ADS/Contract.h"#include <cstddef>#include <cstdint>#include <string>#include <type_traits>#include <vector>#include "ADS/string/impl/Segmentations.tpp"Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Functions | |
| template<class S> requires std::is_class_v< S > | |
| std::uint64_t | ADS::countSegmentations (const S &X, const std::vector< S > &words) |
| the number of ways of writing \( X \) as a sequence of the words, modulo \( 2^{64} \); a word repeated in the list counts once for each copy; 1 for the empty \( X \) | |
| std::uint64_t | ADS::countSegmentations (const std::string &X, const std::vector< std::string > &words) |
| the count of countSegmentations() above, on std::string (or literals) | |
| std::uint64_t | ADS::countDecodings (const std::vector< int > &digits) |
| the number of readings of the digits as letters \( A = 1 , \ldots , Z = 26 \), modulo \( 2^{64} \); 1 for no digits | |
The number of ways of writing a sequence \( X \) of \( n \) items as a concatenation of words, the counting version of the word break problem [see WordBreak.h, which finds one of them].
The counts grow exponentially with \( n \), and they are given modulo \( 2^{64} \). countSegmentations() takes any sequence S with size(), operator[] and the comparison of its items; the overload on std::string also takes string literals.
The contracts [see Contract.h]: no word is empty, and the digits are in \( 0 .. 9 \). The functions are defined in Segmentations.tpp.