fix loop | by Perplex

This commit is contained in:
千住柱間 2024-05-16 21:48:06 -04:00
parent 84f6fb2c70
commit 7508ce6d0d
Signed by: hashirama
GPG key ID: 53E62470A86BC185
2 changed files with 5 additions and 2 deletions

BIN
a.out Executable file

Binary file not shown.

View file

@ -45,9 +45,8 @@ int main(int argc, char* argv[]) {
const auto trie = xcdat::load<xcdat::trie_15_type>(dict_file); const auto trie = xcdat::load<xcdat::trie_15_type>(dict_file);
std::vector<std::string> substrings; std::vector<std::string> substrings;
std::vector<Entry> results;
while (!search_string.empty()) { while (!search_string.empty()) {
std::vector<Entry> results;
auto itr = trie.make_prefix_iterator(search_string); auto itr = trie.make_prefix_iterator(search_string);
while (itr.next()) { while (itr.next()) {
@ -79,9 +78,13 @@ int main(int argc, char* argv[]) {
if (pos != std::string::npos) { if (pos != std::string::npos) {
search_string.erase(0, pos + smallest_prefix.length()); search_string.erase(0, pos + smallest_prefix.length());
} }
else break;
std::cout << search_string << std::endl; std::cout << search_string << std::endl;
if (smallest_prefix.length() == 0)
break;
if (debug_mode) { if (debug_mode) {
raw_output += search_string + '\n'; raw_output += search_string + '\n';
} }