This commit is contained in:
邹晓航
2015-02-14 13:47:07 +08:00
parent 02c3088e8a
commit 9a13d7acc9
4 changed files with 64 additions and 3 deletions

View File

@@ -79,6 +79,7 @@ TinySTL
* avl_tree100%
* suffix_array100%
* directed_graph100%
* trie tree100%
##TinySTL单元测试(原单元测试代码逐步)
* pair100%
@@ -97,6 +98,7 @@ TinySTL
* avl_tree100%
* unordered_set100%
* directed_graph100%
* trie tree100%
#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)
![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<std::string> 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)

View File

@@ -99,6 +99,7 @@
<ClCompile Include="Test\StackTest.cpp" />
<ClCompile Include="Test\StringTest.cpp" />
<ClCompile Include="Test\SuffixArrayTest.cpp" />
<ClCompile Include="Test\TrieTreeTest.cpp" />
<ClCompile Include="Test\Unordered_setTest.cpp" />
<ClCompile Include="Test\VectorTest.cpp" />
</ItemGroup>
@@ -146,6 +147,7 @@
<ClInclude Include="Test\StringTest.h" />
<ClInclude Include="Test\SuffixArrayTest.h" />
<ClInclude Include="Test\TestUtil.h" />
<ClInclude Include="Test\TrieTreeTest.h" />
<ClInclude Include="Test\Unordered_setTest.h" />
<ClInclude Include="Test\VectorTest.h" />
<ClInclude Include="TrieTree.h" />
@@ -164,6 +166,10 @@
<Image Include="ScreenShots\graph_bfs.png" />
<Image Include="ScreenShots\graph_dfs.png" />
<Image Include="ScreenShots\suffix_array.png" />
<Image Include="ScreenShots\trie_tree.png" />
</ItemGroup>
<ItemGroup>
<Text Include="TestData\trie_tree_test.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@@ -25,6 +25,9 @@
<Filter Include="Detail">
<UniqueIdentifier>{7dd5c5f0-33b6-44c6-b2b9-d4c0ec1d4c13}</UniqueIdentifier>
</Filter>
<Filter Include="TestData">
<UniqueIdentifier>{676114e9-f556-46bf-9f51-65d820758de2}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Profiler\Profiler.cpp">
@@ -90,6 +93,9 @@
<ClCompile Include="Detail\TireTree.cpp">
<Filter>Detail</Filter>
</ClCompile>
<ClCompile Include="Test\TrieTreeTest.cpp">
<Filter>Test</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="TypeTraits.h">
@@ -245,6 +251,9 @@
<ClInclude Include="TrieTree.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Test\TrieTreeTest.h">
<Filter>Test</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\README.md" />
@@ -265,5 +274,13 @@
<Image Include="ScreenShots\graph2.png">
<Filter>ScreenShots</Filter>
</Image>
<Image Include="ScreenShots\trie_tree.png">
<Filter>ScreenShots</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<Text Include="TestData\trie_tree_test.txt">
<Filter>TestData</Filter>
</Text>
</ItemGroup>
</Project>

View File

@@ -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();