提交 9510bc1b 编写于 作者: 邹晓航

No commit message

No commit message
上级 2febc598
......@@ -46,6 +46,7 @@ TinySTL
* list:100%
* unordered_set:100%
* unique_ptr:100%
* shared_ptr:100%
* STL Algorithms:
* fill:100%
* fill_n:100%
......@@ -103,6 +104,7 @@ TinySTL
* directed_graph:100%
* trie tree:100%
* unique_ptr:100%
* shared_ptr:100%
#TinySTL性能测试:
###测试环境:Windows 7 && VS2013 && release模式
......@@ -530,4 +532,52 @@ TinySTL
}
std::cout << std::endl;
![image](https://raw.githubusercontent.com/zouxiaohang/TinySTL/master/TinySTL/ScreenShots/trie_tree.png)
\ No newline at end of file
![image](https://raw.githubusercontent.com/zouxiaohang/TinySTL/master/TinySTL/ScreenShots/trie_tree.png)
####(17):shared_ptr
shared_ptr<int> sp1(new int(10));
assert(*(sp1.get()) == 10);
shared_ptr<int> sp2(new int(1), default_delete<int>());
assert(sp2.use_count() == 1);
auto sp3(sp2);
assert(sp3.use_count() == 2);
auto sp4 = sp2;
assert(sp4.use_count() == 3);
assert(sp2.get() == sp3.get() && sp2.get() == sp4.get());
assert(sp2 == sp3 && !(sp2 != sp4));
shared_ptr<string> sp5(new string("hello"));
assert(*sp5 == "hello");
sp5->append(" world");
assert(*sp5 == "hello world");
auto sp6 = make_shared<string>(10, '0');
assert(*sp6 == "0000000000");
shared_ptr<int> spp;
assert(spp == nullptr);
assert(!(spp != nullptr));
####(18):unique_ptr
auto up = make_unique<string>(10, '0');
up->append("111");
assert(*up == "0000000000111");
up.release();
assert(up == nullptr);
up.reset(new string("hello"));
assert(*up == "hello");
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册