News for hackers. Stuff that matters.
Re:Simple Trie Implementation in C++11 by egwor on Sunday July 21, 2019 @04:39PM (#20493520)
I tried giving this a run from CLion and it crashes if I search first, see

#include "trie.hpp" #include <iostream>

int main() { trie<char16_t> trie;

    // Greek
    std::cout << trie.search(u"υπολογιστής") << std::endl;
    std::cout << trie.search(u"υπολογιστης") << std::endl;

    // English
    std::cout << trie.search(u"computer") << std::endl;
    std::cout << trie.search(u"compute") << std::endl;


    // Greek
  trie.insert(u"υπολογιστής"); //crash


  // English
  trie.insert(u"computer");

  // Greek
  std::cout << trie.search(u"υπολογιστής") << std::endl;
  std::cout << trie.search(u"υπολογιστης") << std::endl;

  // English
  std::cout << trie.search(u"computer") << std::endl;
  std::cout << trie.search(u"compute") << std::endl;

  return 0;
}
Re:Simple Trie Implementation in C++11 by xorz57 on Sunday July 21, 2019 @05:20PM (#20493736)
My apologies. I updated the post! Now it works just fine!
Re:Simple Trie Implementation in C++11 by nemetroid on Sunday July 21, 2019 @06:08PM (#20493973)
There's still an issue if you insert something you've searched for first, e.g.:

  trie<char16_t> trie;

  trie.insert(u"a");
  trie.search(u"ab");
  trie.insert(u"ab");
Re:Simple Trie Implementation in C++11 by xorz57 on Sunday July 21, 2019 @07:11PM (#20494274)
Re:Simple Trie Implementation in C++11 by xorz57 on Sunday July 21, 2019 @06:17PM (#20494019)
I verify this is true! I am working on it!