This commit is contained in:
邹晓航
2015-02-11 11:02:21 +08:00
parent a48c17b0bf
commit a98ecca3db
4 changed files with 87 additions and 2 deletions

View File

@@ -78,6 +78,7 @@ TinySTL
* binary_search_tree100%
* avl_tree100%
* suffix_array100%
*directed_graph100%
##TinySTL单元测试(原单元测试代码逐步)
* pair100%
@@ -95,6 +96,7 @@ TinySTL
* binary_search_tree100%
* avl_tree100%
* unordered_set100%
*directed_graph100%
#TinySTL性能测试:
###测试环境Windows 7 && VS2013 && release模式
@@ -420,7 +422,7 @@ TinySTL
####(4):sort
####(14):sort
std::random_device rd;
const int len = 10000000;
@@ -439,4 +441,51 @@ TinySTL
|TinySTL::sort|1000万|1547|
|std::sort|10万|13|
|std::sort|100万|147|
|std::sort|1000万|1730|
|std::sort|1000万|1730|
####(15):directed_graph
template<class Index, class Value>
using dGraph = TinySTL::directed_graph < Index, Value > ;
dGraph<int, int> g;
dGraph<int, int>::nodes_set_type set1, set2, set3;
set1.push_back(g.make_node(1, 11));
set1.push_back(g.make_node(2, 22));
set1.push_back(g.make_node(3, 33));
g.add_node(g.make_node(0, 0), set1);
set2.push_back(g.make_node(5, 55));
set2.push_back(g.make_node(6, 66));
set2.push_back(g.make_node(7, 77));
g.add_node(g.make_node(1, 11), set2);
set3.push_back(g.make_node(12, 1212));
set3.push_back(g.make_node(13, 1313));
set3.push_back(g.make_node(14, 1414));
g.add_node(7, set3);
g.make_edge(12, 2);
g.make_edge(12, 3);
g.make_edge(12, 0);
std::cout << "graph after add nodes:" << std::endl;
std::cout << g.to_string();
auto func = [](const dGraph<int, int>::node_type& node){
std::cout << "[" << node.first << "," << node.second << "]" << std::endl;
};
std::cout << "graph DFS from node(1, 11):" << std::endl;
g.DFS(1, func);
std::cout << "graph BFS from node(1, 11):" << std::endl;
g.BFS(1, func);
std::cout << "graph after delete node(7, 77):" << std::endl;
g.delete_node(dGraph<int, int>::node_type(7, 77));
std::cout << g.to_string();
![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)

View File

@@ -90,6 +90,7 @@
<ClCompile Include="Test\BitmapTest.cpp" />
<ClCompile Include="Test\CircularBufferTest.cpp" />
<ClCompile Include="Test\DequeTest.cpp" />
<ClCompile Include="Test\GraphTest.cpp" />
<ClCompile Include="Test\ListTest.cpp" />
<ClCompile Include="Test\PairTest.cpp" />
<ClCompile Include="Test\PriorityQueueTest.cpp" />
@@ -115,10 +116,12 @@
<ClInclude Include="Detail\Bitmap.impl.h" />
<ClInclude Include="Detail\CircularBuffer.impl.h" />
<ClInclude Include="Detail\Deque.impl.h" />
<ClInclude Include="Detail\Graph.impl.h" />
<ClInclude Include="Detail\List.impl.h" />
<ClInclude Include="Detail\Unordered_set.impl.h" />
<ClInclude Include="Detail\Vector.impl.h" />
<ClInclude Include="Functional.h" />
<ClInclude Include="Graph.h" />
<ClInclude Include="Iterator.h" />
<ClInclude Include="List.h" />
<ClInclude Include="Profiler\Profiler.h" />
@@ -133,6 +136,7 @@
<ClInclude Include="Test\BitmapTest.h" />
<ClInclude Include="Test\CircularBufferTest.h" />
<ClInclude Include="Test\DequeTest.h" />
<ClInclude Include="Test\GraphTest.h" />
<ClInclude Include="Test\ListTest.h" />
<ClInclude Include="Test\PairTest.h" />
<ClInclude Include="Test\PriorityQueueTest.h" />
@@ -153,6 +157,10 @@
<None Include="..\README.md" />
</ItemGroup>
<ItemGroup>
<Image Include="ScreenShots\graph1.png" />
<Image Include="ScreenShots\graph2.png" />
<Image Include="ScreenShots\graph_bfs.png" />
<Image Include="ScreenShots\graph_dfs.png" />
<Image Include="ScreenShots\suffix_array.png" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@@ -84,6 +84,9 @@
<ClCompile Include="Test\Unordered_setTest.cpp">
<Filter>Test</Filter>
</ClCompile>
<ClCompile Include="Test\GraphTest.cpp">
<Filter>Test</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="TypeTraits.h">
@@ -227,6 +230,15 @@
<ClInclude Include="Test\Unordered_setTest.h">
<Filter>Test</Filter>
</ClInclude>
<ClInclude Include="Graph.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Detail\Graph.impl.h">
<Filter>Detail</Filter>
</ClInclude>
<ClInclude Include="Test\GraphTest.h">
<Filter>Test</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\README.md" />
@@ -235,5 +247,17 @@
<Image Include="ScreenShots\suffix_array.png">
<Filter>ScreenShots</Filter>
</Image>
<Image Include="ScreenShots\graph_bfs.png">
<Filter>ScreenShots</Filter>
</Image>
<Image Include="ScreenShots\graph_dfs.png">
<Filter>ScreenShots</Filter>
</Image>
<Image Include="ScreenShots\graph1.png">
<Filter>ScreenShots</Filter>
</Image>
<Image Include="ScreenShots\graph2.png">
<Filter>ScreenShots</Filter>
</Image>
</ItemGroup>
</Project>

View File

@@ -9,6 +9,7 @@
#include "Test\BinarySearchTreeTest.h"
#include "Test\CircularBufferTest.h"
#include "Test\DequeTest.h"
#include "Test\GraphTest.h"
#include "Test\ListTest.h"
#include "Test\PairTest.h"
#include "Test\PriorityQueueTest.h"
@@ -19,6 +20,8 @@
#include "Test\Unordered_setTest.h"
#include "Test\VectorTest.h"
#include "Graph.h"
using namespace TinySTL::Profiler;
int main(){
@@ -29,6 +32,7 @@ int main(){
TinySTL::CircularBufferTest::testAllCases();
TinySTL::DequeTest::testAllCases();
TinySTL::ListTest::testAllCases();
TinySTL::GraphTest::testAllCases();
TinySTL::PairTest::testAllCases();
TinySTL::PriorityQueueTest::testAllCases();
TinySTL::QueueTest::testAllCases();