Wordsearch Solver
Classes | Functions
dictionary_std_vector Namespace Reference

namespace dictionary_std_vector More...

Classes

class  DictionaryStdVector
 Solver implementation using a sorted std::vector. More...
 

Functions

std::optional< std::string > calc_stop (std::string word)
 From word, calculate the last possible string we would need to search to, for a valid further() call, to optimise calls in contains_further(). More...
 
std::ostream & operator<< (std::ostream &os, const DictionaryStdVector &dsv)
 

Detailed Description

namespace dictionary_std_vector

Namespace dictionary_std_vector.

Function Documentation

◆ calc_stop()

std::optional<std::string> dictionary_std_vector::calc_stop ( std::string  word)
inline

From word, calculate the last possible string we would need to search to, for a valid further() call, to optimise calls in contains_further().

Parameters
[in]wordTo allow binary searching more efficiently when using a word and suffixes, we need to be able to calculate lower and upper limits on the search in a lexicographically sorted list of words. std::lower_bound(word) gives the start. This will calculate the end. Returns empty optional if no value ie. the end iterator should be used. Usually this is simple ie. zap -> zaq (increment last) But if last is the highest allowed value, then we must keep removing the last element until we have an end that isn't the highest allowed.