diff --git a/README.md b/README.md index e4cee33a4dd2825cf60c98e07350f1d3ae5e55df..ced52cf29f3a9abd00756a31a4aec253b0c71c2a 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ TinySTL * avl_tree:100% * suffix_array:100% * directed_graph:100% + * trie tree:100% ##TinySTL单元测试(原单元测试代码逐步): * pair:100% @@ -97,6 +98,7 @@ TinySTL * avl_tree:100% * unordered_set:100% * directed_graph:100% + * trie tree:100% #TinySTL性能测试: ###测试环境:Windows 7 && VS2013 && release模式 @@ -488,4 +490,40 @@ TinySTL ![image](https://raw.githubusercontent.com/zouxiaohang/TinySTL/master/TinySTL/ScreenShots/graph1.png) ![image](https://raw.githubusercontent.com/zouxiaohang/TinySTL/master/TinySTL/ScreenShots/graph_dfs.png) ![image](https://raw.githubusercontent.com/zouxiaohang/TinySTL/master/TinySTL/ScreenShots/graph_bfs.png) -![image](https://raw.githubusercontent.com/zouxiaohang/TinySTL/master/TinySTL/ScreenShots/graph2.png) \ No newline at end of file +![image](https://raw.githubusercontent.com/zouxiaohang/TinySTL/master/TinySTL/ScreenShots/graph2.png) + + + + + +####(16):trie tree + + TinySTL::trie_tree t; + std::ifstream in; + in.open("C:\\Users\\zxh\\Desktop\\trie_tree_test.txt"); + std::vector v; + std::string s; + while (in){ + in >> s; + v.push_back(s); + } + ProfilerInstance::start(); + for (const auto& str : v){ + t.insert(TinySTL::string(str.data())); + } + ProfilerInstance::finish(); + std::cout << "build trie tree costs " << ProfilerInstance::millisecond() << "ms" << std::endl; + + ProfilerInstance::start(); + auto res = t.get_word_by_prefix("v"); + ProfilerInstance::finish(); + std::cout << "get word by prefix \"v\" costs " << ProfilerInstance::millisecond() << "ms" << std::endl; + auto i = 0; + for (const auto& str : res){ + ++i; + if (i % 10 == 0) std::cout << std::endl; + std::cout << str << " "; + } + std::cout << std::endl; + +![image](https://raw.githubusercontent.com/zouxiaohang/TinySTL/master/TinySTL/ScreenShots/trie_tree.png) \ No newline at end of file diff --git a/TinySTL/TinySTL.vcxproj b/TinySTL/TinySTL.vcxproj index ea043591baed64790f85bea8c633ca45a915b4e7..02079421334def20639756274134458ea7ecb207 100644 --- a/TinySTL/TinySTL.vcxproj +++ b/TinySTL/TinySTL.vcxproj @@ -99,6 +99,7 @@ + @@ -146,6 +147,7 @@ + @@ -164,6 +166,10 @@ + + + + diff --git a/TinySTL/TinySTL.vcxproj.filters b/TinySTL/TinySTL.vcxproj.filters index 88293bcd9d44370cfa429853ca34c0eb2dd20313..41a6b296326a4ef7a9136fad60f7b9d2c47414a8 100644 --- a/TinySTL/TinySTL.vcxproj.filters +++ b/TinySTL/TinySTL.vcxproj.filters @@ -25,6 +25,9 @@ {7dd5c5f0-33b6-44c6-b2b9-d4c0ec1d4c13} + + {676114e9-f556-46bf-9f51-65d820758de2} + @@ -90,6 +93,9 @@ Detail + + Test + @@ -245,6 +251,9 @@ 头文件 + + Test + @@ -265,5 +274,13 @@ ScreenShots + + ScreenShots + + + + + TestData + \ No newline at end of file diff --git a/TinySTL/main.cpp b/TinySTL/main.cpp index 0ad1d23d9e47c582e4f51e0bb5ec7dd531632e9a..9741d4e5804e9da40e36b0fbf0da454f451dd2ee 100644 --- a/TinySTL/main.cpp +++ b/TinySTL/main.cpp @@ -17,11 +17,10 @@ #include "Test\StackTest.h" #include "Test\StringTest.h" #include "Test\SuffixArrayTest.h" +#include "Test\TrieTreeTest.h" #include "Test\Unordered_setTest.h" #include "Test\VectorTest.h" -#include "Graph.h" - using namespace TinySTL::Profiler; int main(){ @@ -39,6 +38,7 @@ int main(){ TinySTL::StackTest::testAllCases(); TinySTL::StringTest::testAllCases(); TinySTL::SuffixArrayTest::testAllCases(); + TinySTL::TrieTreeTest::testAllCases(); TinySTL::Unordered_setTest::testAllCases(); TinySTL::VectorTest::testAllCases();