容器的例子,大家都知道map 在插入元素的时候会自动排序,默认是根据key 从小到大排序,看map 的定义:
// TEMPLATE CLASS map
template Kty,... class _Ty,
class _Pr = lessKty>,
class _Alloc = allocatorpairconst _Kty..., _Ty> > >
class map
: public _TreeKty, _Ty, _Pr, _Alloc, false> >
{
// ordered...Ty, _Ty, bool>
{
// functor for operator<
bool operator()(const _Ty &_Left, const _Ty &_Right...我们也可以在定义的时候传递第三个参数,如map > mapTest; 则插入时按key 值从大到小排序(less,
greater 都是STL内置的类