// // main.cpp // // Created by @YangZai on 26.05.21. // #include"Trie.hpp"
#include<iostream> #include<vector>
voidtest_string() { cout << "N: char, M: string:" << endl; vector<string> list = {"hello world!", "hello"}; string a = "hello"; Trie<char, string> trie; for (auto &i: list) { trie.insert(i); } cout << "\ta" << (trie.search(a) ? " is" : " isn't") << " in the Trie" << endl; cout << "\ta" << (trie.startWith(a) ? " is" : " isn't") << " one prefix in the Trie" << endl; }
voidtest_vector() { cout << "N: int, M: vector<int>:" << endl; vector<vector<int>> list = {{6, 5, 4, 3, 2, 1}, {6, 5, 4}}; vector<int> a = {6, 5, 4}; Trie<int, vector<int>> trie; for (auto &i: list) { trie.insert(i); } cout << "\ta" << (trie.search(a) ? " is" : " isn't") << " in the Trie" << endl; cout << "\ta" << (trie.startWith(a) ? " is" : " isn't") << " one prefix in the Trie" << endl; }
intmain(int argc, constchar * argv[]) { test_string(); test_vector(); return0; } /* N: char, M: string: a is in the Trie a is one prefix in the Trie N: int, M: vector<int>: a is in the Trie a is one prefix in the Trie */