stl 中的一个基本有关问题
stl 中的一个基本问题
下面是stl中关于set(集合)的三个构造函数,我不理解的是第二个什么意思?
pair <iterator, bool> insert(
const value_type& _Val
);
iterator insert(
iterator _Where,
const value_type& _Val
);
template <class InputIterator>
void insert(
InputIterator _First,
InputIterator _Last
);
集合就是一些松散的对象组成的,相互之间没什么关系,
_Where
The place to start searching for the correct point of insertion. (Insertion can occur in amortized constant time, instead of logarithmic time, if the insertion point immediately follows _Where.)
为什么要这样,难道不是每次插入的时候都从尾部插入吗?
------解决方案--------------------
set是有序的关联容器, 当然不是从尾部插入!
下面是stl中关于set(集合)的三个构造函数,我不理解的是第二个什么意思?
pair <iterator, bool> insert(
const value_type& _Val
);
iterator insert(
iterator _Where,
const value_type& _Val
);
template <class InputIterator>
void insert(
InputIterator _First,
InputIterator _Last
);
集合就是一些松散的对象组成的,相互之间没什么关系,
_Where
The place to start searching for the correct point of insertion. (Insertion can occur in amortized constant time, instead of logarithmic time, if the insertion point immediately follows _Where.)
为什么要这样,难道不是每次插入的时候都从尾部插入吗?
------解决方案--------------------
set是有序的关联容器, 当然不是从尾部插入!