Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #ifndef RADIX_TRIE_H
  2. #define RADIX_TRIE_H
  3. #include <iostream>
  4. #include <string>
  5. #include <vector>
  6.  
  7. class radix_trie {
  8. char Value;
  9. public:
  10. std::string children_characters;
  11. std::vector<radix_trie> children;
  12. radix_trie() { Value = 0; };
  13. radix_trie(char pValue) { Value = pValue; };
  14. ~radix_trie() {};
  15. void add_string(std::string input) {
  16. std::cout << input << std::endl;
  17. for( int i = 0, radix_trie* it = this; i < input.length(); i++ ) {
  18. if( it.children_characters.find( input[i] == std::string::npos ) ) {
  19. it.children_characters.append( input[i] );
  20. }
  21. else
  22. {
  23. it = it.children[it.children_characters.find(input[i])];
  24. continue;
  25. }
  26. it.children.push_back(it = new radix_trie(input[i]));
  27. }
  28. }
  29. void delete_string(const std::string input) {
  30.  
  31. }
  32. };
  33. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement