From 10b7b6707337211aa1866fef6e9b815ecac3a253 Mon Sep 17 00:00:00 2001 From: huihut Date: Thu, 15 Aug 2019 22:59:02 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90@foolishflyfox=20=E6=8F=90=E4=BE=9B?= =?UTF-8?q?=E3=80=91unordered=5Fset=E3=80=81unordered=5Fmultiset=E3=80=81u?= =?UTF-8?q?nordered=5Fmap=E3=80=81unordered=5Fmultimap=20=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/huihut/interview/issues/48 --- README.md | 15 ++++++++------- docs/README.md | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index d5f6d9d..bde9619 100644 --- a/README.md +++ b/README.md @@ -1274,10 +1274,11 @@ class doSomething(Flyable *obj) // 做些事情 容器 | 底层数据结构 | 时间复杂度 | 有无序 | 可不可重复 | 其他 ---|---|---|---|---|--- -[array](https://github.com/huihut/interview/tree/master/STL#array)|数组|随机读改 O(1)|无序|可重复|支持快速随机访问 -[vector](https://github.com/huihut/interview/tree/master/STL#vector)|数组|随机读改、尾部插入、尾部删除 O(1)
头部插入、头部删除 O(n)|无序|可重复|支持快速随机访问 -[list](https://github.com/huihut/interview/tree/master/STL#list)|双向链表|插入、删除 O(1)
随机读改 O(n)|无序|可重复|支持快速增删 +[array](https://github.com/huihut/interview/tree/master/STL#array)|数组|随机读改 O(1)|无序|可重复|支持随机访问 +[vector](https://github.com/huihut/interview/tree/master/STL#vector)|数组|随机读改、尾部插入、尾部删除 O(1)
头部插入、头部删除 O(n)|无序|可重复|支持随机访问 [deque](https://github.com/huihut/interview/tree/master/STL#deque)|双端队列|头尾插入、头尾删除 O(1)|无序|可重复|一个中央控制器 + 多个缓冲区,支持首尾快速增删,支持随机访问 +[forward_list](https://github.com/huihut/interview/tree/master/STL#forward_list)|单向链表|插入、删除 O(1)|无序|可重复|不支持随机访问 +[list](https://github.com/huihut/interview/tree/master/STL#list)|双向链表|插入、删除 O(1)|无序|可重复|不支持随机访问 [stack](https://github.com/huihut/interview/tree/master/STL#stack)|deque / list|顶部插入、顶部删除 O(1)|无序|可重复|deque 或 list 封闭头端开口,不用 vector 的原因应该是容量大小有限制,扩容耗时 [queue](https://github.com/huihut/interview/tree/master/STL#queue)|deque / list|尾部插入、头部删除 O(1)|无序|可重复|deque 或 list 封闭头端开口,不用 vector 的原因应该是容量大小有限制,扩容耗时 [priority_queue](https://github.com/huihut/interview/tree/master/STL#priority_queue)|vector + max-heap|插入、删除 O(log2n)|有序|可重复|vector容器+heap处理规则 @@ -1285,10 +1286,10 @@ class doSomething(Flyable *obj) // 做些事情 [multiset](https://github.com/huihut/interview/tree/master/STL#multiset)|红黑树|插入、删除、查找 O(log2n)|有序|可重复| [map](https://github.com/huihut/interview/tree/master/STL#map)|红黑树|插入、删除、查找 O(log2n)|有序|不可重复| [multimap](https://github.com/huihut/interview/tree/master/STL#multimap)|红黑树|插入、删除、查找 O(log2n)|有序|可重复| -hash_set|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|不可重复| -hash_multiset|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|可重复| -hash_map|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|不可重复| -hash_multimap|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|可重复| +[unordered_set](https://github.com/huihut/interview/tree/master/STL#unordered_set)|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|不可重复| +[unordered_multiset](https://github.com/huihut/interview/tree/master/STL#unordered_multiset)|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|可重复| +[unordered_map](https://github.com/huihut/interview/tree/master/STL#unordered_map)|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|不可重复| +[unordered_multimap](https://github.com/huihut/interview/tree/master/STL#unordered_multimap)|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|可重复| ### STL 算法 diff --git a/docs/README.md b/docs/README.md index 3e0e4b5..7b756bc 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1238,10 +1238,11 @@ class doSomething(Flyable *obj) // 做些事情 容器 | 底层数据结构 | 时间复杂度 | 有无序 | 可不可重复 | 其他 ---|---|---|---|---|--- -[array](https://github.com/huihut/interview/tree/master/STL#array)|数组|随机读改 O(1)|无序|可重复|支持快速随机访问 -[vector](https://github.com/huihut/interview/tree/master/STL#vector)|数组|随机读改、尾部插入、尾部删除 O(1)
头部插入、头部删除 O(n)|无序|可重复|支持快速随机访问 -[list](https://github.com/huihut/interview/tree/master/STL#list)|双向链表|插入、删除 O(1)
随机读改 O(n)|无序|可重复|支持快速增删 +[array](https://github.com/huihut/interview/tree/master/STL#array)|数组|随机读改 O(1)|无序|可重复|支持随机访问 +[vector](https://github.com/huihut/interview/tree/master/STL#vector)|数组|随机读改、尾部插入、尾部删除 O(1)
头部插入、头部删除 O(n)|无序|可重复|支持随机访问 [deque](https://github.com/huihut/interview/tree/master/STL#deque)|双端队列|头尾插入、头尾删除 O(1)|无序|可重复|一个中央控制器 + 多个缓冲区,支持首尾快速增删,支持随机访问 +[forward_list](https://github.com/huihut/interview/tree/master/STL#forward_list)|单向链表|插入、删除 O(1)|无序|可重复|不支持随机访问 +[list](https://github.com/huihut/interview/tree/master/STL#list)|双向链表|插入、删除 O(1)|无序|可重复|不支持随机访问 [stack](https://github.com/huihut/interview/tree/master/STL#stack)|deque / list|顶部插入、顶部删除 O(1)|无序|可重复|deque 或 list 封闭头端开口,不用 vector 的原因应该是容量大小有限制,扩容耗时 [queue](https://github.com/huihut/interview/tree/master/STL#queue)|deque / list|尾部插入、头部删除 O(1)|无序|可重复|deque 或 list 封闭头端开口,不用 vector 的原因应该是容量大小有限制,扩容耗时 [priority_queue](https://github.com/huihut/interview/tree/master/STL#priority_queue)|vector + max-heap|插入、删除 O(log2n)|有序|可重复|vector容器+heap处理规则 @@ -1249,10 +1250,10 @@ class doSomething(Flyable *obj) // 做些事情 [multiset](https://github.com/huihut/interview/tree/master/STL#multiset)|红黑树|插入、删除、查找 O(log2n)|有序|可重复| [map](https://github.com/huihut/interview/tree/master/STL#map)|红黑树|插入、删除、查找 O(log2n)|有序|不可重复| [multimap](https://github.com/huihut/interview/tree/master/STL#multimap)|红黑树|插入、删除、查找 O(log2n)|有序|可重复| -hash_set|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|不可重复| -hash_multiset|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|可重复| -hash_map|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|不可重复| -hash_multimap|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|可重复| +[unordered_set](https://github.com/huihut/interview/tree/master/STL#unordered_set)|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|不可重复| +[unordered_multiset](https://github.com/huihut/interview/tree/master/STL#unordered_multiset)|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|可重复| +[unordered_map](https://github.com/huihut/interview/tree/master/STL#unordered_map)|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|不可重复| +[unordered_multimap](https://github.com/huihut/interview/tree/master/STL#unordered_multimap)|哈希表|插入、删除、查找 O(1) 最差 O(n)|无序|可重复| ### STL 算法 -- GitLab