由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - std::map 为什么没有排序呢
相关主题
c++ pointers are iterators, why?How to send a structure containing a pointer over socket?
Anybody help me on these questions?通过日志分析yarn app实际内存用量
java初学者求指点这段codeGo’s path to becoming a Top 10 if not Top 5 language
Is it safe to use unique_ptr with STL container?C ++ 问题
Re: 110道C++面试题目,你会做多少? (转载)请教一个关于字符指针的简单问题
一个C++的概念问题一个面试题目,用C实现
弱弱的问问hash, hashtable? (转载)问个字符串的基本问题
Associative container 是 set, multiset, map, multimap 这些东西吗?这段代码为何要这样做?
相关话题的讨论汇总
话题: container话题: sorted话题: complexity话题: std
进入Programming版参与讨论
1 (共1页)
e****s
发帖数: 46
1
我如果用std::map存放一些字符串,发现里面的字符串并没有排序
如果用std::map存放一些字符,发现字符是排序的,请问哪位大侠给解释一
下为什么
s******o
发帖数: 2233
2
in the first case, it's ranked by pointer addresses...

【在 e****s 的大作中提到】
: 我如果用std::map存放一些字符串,发现里面的字符串并没有排序
: 如果用std::map存放一些字符,发现字符是排序的,请问哪位大侠给解释一
: 下为什么

L*******s
发帖数: 63
3
Cause C-Style strings (char*) are not compared by < or >.
Use std::string or any string classes that have those operator overloaded.

【在 e****s 的大作中提到】
: 我如果用std::map存放一些字符串,发现里面的字符串并没有排序
: 如果用std::map存放一些字符,发现字符是排序的,请问哪位大侠给解释一
: 下为什么

t*****n
发帖数: 4908
4
http://www.sgi.com/tech/stl/SortedAssociativeContainer.html
A Sorted Associative Container is a type of Associative Container. Sorted
Associative Containers use an ordering relation on their keys; two keys are
considered to be equivalent if neither one is less than the other. (If the
ordering relation is case-insensitive string comparison, for example, then
the keys "abcde" and "aBcDe" are equivalent.)
Sorted Associative Containers guarantee that the complexity for most
operations is never worse than logarithmic [1], and they also guarantee that
their elements are always sorted in ascending order by key.
[1] This is a much stronger guarantee than the one provided by Associative
Container. The guarantees in Associative Container only apply to average
complexity; worst case complexity is allowed to be greater. Sorted
Associative Container, however, provides an upper limit on worst case
complexity.
1 (共1页)
进入Programming版参与讨论
相关主题
这段代码为何要这样做?Re: 110道C++面试题目,你会做多少? (转载)
初学C,对什么该free一直搞不明白一个C++的概念问题
如何动态分配内存来存储输入的不定长的字符串,char not string类型的弱弱的问问hash, hashtable? (转载)
[合集] 面试问题Associative container 是 set, multiset, map, multimap 这些东西吗?
c++ pointers are iterators, why?How to send a structure containing a pointer over socket?
Anybody help me on these questions?通过日志分析yarn app实际内存用量
java初学者求指点这段codeGo’s path to becoming a Top 10 if not Top 5 language
Is it safe to use unique_ptr with STL container?C ++ 问题
相关话题的讨论汇总
话题: container话题: sorted话题: complexity话题: std