|
ADS
Algorithms and Data Structures
|
The search by prefix in a sorted dictionary of \( n \) strings, beyond the book: the strings prefixed by \( P \) are consecutive, between the lexicographic position of \( P \) (the number of strings smaller than \( P \)) and that of \( P\# \), \( \# \) being a character larger than all the others, so that two lexicographic searches give their range. More...
#include "ADS/Contract.h"#include "ADS/search/BinarySearch.h"#include <algorithm>#include <cstddef>#include <cstdint>#include <optional>#include <string>#include <string_view>#include <utility>#include <vector>#include "ADS/string/impl/PrefixSearch.tpp"Go to the source code of this file.
Classes | |
| class | ADS::BinnedSearch |
| the search by interpolation of a sorted array of integers by bins More... | |
| class | ADS::BinnedStringSearch |
| the search by interpolation of a sorted array of strings by bins More... | |
Namespaces | |
| namespace | ADS |
Functions | |
| std::size_t | ADS::lexicographicPosition (const std::vector< std::string > &A, std::string_view Q) |
| the number of strings of the sorted \( A \) smaller than \( Q \) | |
| std::size_t | ADS::prefixEnd (const std::vector< std::string > &A, std::string_view P) |
| the number of strings of the sorted \( A \) smaller than \( P\# \), i.e., smaller than \( P \) or prefixed by \( P \) | |
| std::pair< std::size_t, std::size_t > | ADS::prefixRange (const std::vector< std::string > &A, std::string_view P) |
| the range \( [ l , r ) \) of the strings of the sorted \( A \) prefixed by \( P \) | |
| std::size_t | ADS::commonPrefixLength (std::string_view a, std::string_view b) |
| the length of the longest common prefix of \( a \) and \( b \), by comparing them from their start | |
The search by prefix in a sorted dictionary of \( n \) strings, beyond the book: the strings prefixed by \( P \) are consecutive, between the lexicographic position of \( P \) (the number of strings smaller than \( P \)) and that of \( P\# \), \( \# \) being a character larger than all the others, so that two lexicographic searches give their range.
The contracts [see Contract.h]: the array sorted, an audit (for the strings by the order of std::string, i.e., of the unsigned characters); each position \( r \) is such that the items before \( r \) are smaller than the pattern and those from \( r \) on are not, a postcondition. The functions are defined in PrefixSearch.tpp.