|
M_node->_M_prev; _Node* __n = (_Node*) __position._M_node; __prev_node->_M_next = __next_node; __next_node->_M_prev = __prev_node; _Destroy(&__n->_M_data); _M_put_node(__n); return iterator((_Node*) __next_node); } iterator erase(iterator __first, iterator __last); void clear() { _Base::clear(); } void resize(size_type __new_size, const _Tp& __x); void resize(size_type __new_size) { this->resize(__new_size, _Tp()); } void pop_front() { erase(begin()); } void pop_back() { iterator __tmp = end(); erase(--__tmp); } list(size_type __n, const _Tp& __value, const allocator_type& __a = allocator_type()): _Base(__a) { insert(begin(), __n, __value); } explicit list(size_type __n): _Base(allocator_type()) { insert(begin(), __n, _Tp()); } /// We don't need any dispatching tricks here, because insert does all of /// that anyway. template
list(_InputIterator __first, _InputIterator __last, const allocator_type& __a = allocator_type()) : _Base(__a) { insert(begin(), __first, __last); } list(const list<_Tp, _Alloc>& __x) : _Base(__x.get_allocator()) { insert(begin(), __x.begin(), __x.end()); } ~list() { } ///善后留给基类中的析构函数 list<_Tp, _Alloc>& operator=(const list<_Tp, _Alloc>& __x); public: /// assign(), a generalized assignment member function. Two /// versions: one that takes a count, and one that takes a range. /// The range version is a member template, so we dispatch on whether /// or not the type is an integer. void assign(size_type __n, const _Tp& __val) { _M_fill_assign(__n, __val); } void _M_fill_assign(size_type __n, const _Tp& __val); template
void assign(_InputIterator __first, _InputIterator __last) { typedef typename _Is_integer<_InputIterator>::_Integral _Integral; _M_assign_dispatch(__first, __last, _Integral()); } template
void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) { _M_fill_assign((size_type) __n, (_Tp) __val); } template
void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, __false_type); protected: ///将[first,last)从原位置中摘下来,插入到position之前 ///这个函数主要通过指针的修改来完成 void transfer(iterator __position, iterator __first, iterator __last) { if (__position != __last) { /// Remove [first, last) from its old position. __last._M_node->_M_prev->_M_next = __position._M_node; __first._M_node->_M_prev->_M_next = __last._M_node; __position._M_node->_M_prev->_M_next = __first._M_node; /// Splice [first, last) into its new position. _List_node_base* __tmp = __position._M_node->_M_prev; __position._M_node->_M_prev = __last._M_node->_M_prev; __last._M_node->_M_prev = __first._M_node->_M_prev; __first._M_node->_M_prev = __tmp; } } public: ///将x链入本链表position之前 void splice(iterator __position, list& __x) { if (!__x.empty()) this->transfer(__position, __x.begin(), __x.end()); } ///将i所指结点摘下来,插入到position之前 void splice(iterator __position, list&, iterator __i) { iterator __j = __i; ++__j; if (__position == __i || __position == __j) return; this->transfer(__position, __i, __j); } void splice(iterator __position, list&, iterator __first, iterator __last) { if (__first != __last) this->transfer(__position, __first, __last); } void remove(const _Tp& __value); void unique(); void merge(list& __x); void reverse(); void sort(); template
void remove_if(_Predicate); template
void unique(_BinaryPredicate); template
void merge(list&, _StrictWeakOrdering); template
void sort(_StrictWeakOrdering); }; template
inline bool operator==(const list<_Tp,_Alloc>& __x, c |