deque.tcc: Wrap overlong lines...
2004-02-01 Paolo Carlini <pcarlini@suse.de> * include/bits/deque.tcc: Wrap overlong lines, constify a few variables, reformat according to the coding standards. * include/bits/list.tcc: Likewise. * include/bits/stl_deque.h: Likewise. * include/bits/stl_function.h: Likewise. * include/bits/stl_iterator.h: Likewise. * include/bits/stl_iterator_base_funcs.h: Likewise. * include/bits/stl_iterator_base_types.h: Likewise. * include/bits/stl_list.h: Likewise. * include/bits/stl_map.h: Likewise. * include/bits/stl_multimap.h: Likewise. * include/bits/stl_multiset.h: Likewise. * include/bits/stl_relops.h: Likewise. * include/bits/stl_set.h: Likewise. From-SVN: r77077
This commit is contained in:
parent
e0a24727f2
commit
f6592a9e2c
@ -1,3 +1,20 @@
|
||||
2004-02-01 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/bits/deque.tcc: Wrap overlong lines, constify
|
||||
a few variables, reformat according to the coding standards.
|
||||
* include/bits/list.tcc: Likewise.
|
||||
* include/bits/stl_deque.h: Likewise.
|
||||
* include/bits/stl_function.h: Likewise.
|
||||
* include/bits/stl_iterator.h: Likewise.
|
||||
* include/bits/stl_iterator_base_funcs.h: Likewise.
|
||||
* include/bits/stl_iterator_base_types.h: Likewise.
|
||||
* include/bits/stl_list.h: Likewise.
|
||||
* include/bits/stl_map.h: Likewise.
|
||||
* include/bits/stl_multimap.h: Likewise.
|
||||
* include/bits/stl_multiset.h: Likewise.
|
||||
* include/bits/stl_relops.h: Likewise.
|
||||
* include/bits/stl_set.h: Likewise.
|
||||
|
||||
2004-02-01 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/bits/stl_bvector.h: Wrap overlong lines, constify
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Deque implementation (out of line) -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -70,16 +70,17 @@ namespace __gnu_norm
|
||||
{
|
||||
const size_type __len = size();
|
||||
if (&__x != this)
|
||||
{
|
||||
if (__len >= __x.size())
|
||||
erase(std::copy(__x.begin(), __x.end(), this->_M_start), this->_M_finish);
|
||||
else
|
||||
{
|
||||
const_iterator __mid = __x.begin() + difference_type(__len);
|
||||
std::copy(__x.begin(), __mid, this->_M_start);
|
||||
insert(this->_M_finish, __mid, __x.end());
|
||||
}
|
||||
}
|
||||
{
|
||||
if (__len >= __x.size())
|
||||
erase(std::copy(__x.begin(), __x.end(), this->_M_start),
|
||||
this->_M_finish);
|
||||
else
|
||||
{
|
||||
const_iterator __mid = __x.begin() + difference_type(__len);
|
||||
std::copy(__x.begin(), __mid, this->_M_start);
|
||||
insert(this->_M_finish, __mid, __x.end());
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -89,17 +90,17 @@ namespace __gnu_norm
|
||||
insert(iterator position, const value_type& __x)
|
||||
{
|
||||
if (position._M_cur == this->_M_start._M_cur)
|
||||
{
|
||||
push_front(__x);
|
||||
return this->_M_start;
|
||||
}
|
||||
{
|
||||
push_front(__x);
|
||||
return this->_M_start;
|
||||
}
|
||||
else if (position._M_cur == this->_M_finish._M_cur)
|
||||
{
|
||||
push_back(__x);
|
||||
iterator __tmp = this->_M_finish;
|
||||
--__tmp;
|
||||
return __tmp;
|
||||
}
|
||||
{
|
||||
push_back(__x);
|
||||
iterator __tmp = this->_M_finish;
|
||||
--__tmp;
|
||||
return __tmp;
|
||||
}
|
||||
else
|
||||
return _M_insert_aux(position, __x);
|
||||
}
|
||||
@ -113,15 +114,15 @@ namespace __gnu_norm
|
||||
++__next;
|
||||
size_type __index = __position - this->_M_start;
|
||||
if (__index < (size() >> 1))
|
||||
{
|
||||
std::copy_backward(this->_M_start, __position, __next);
|
||||
pop_front();
|
||||
}
|
||||
{
|
||||
std::copy_backward(this->_M_start, __position, __next);
|
||||
pop_front();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::copy(__next, this->_M_finish, __position);
|
||||
pop_back();
|
||||
}
|
||||
{
|
||||
std::copy(__next, this->_M_finish, __position);
|
||||
pop_back();
|
||||
}
|
||||
return this->_M_start + __index;
|
||||
}
|
||||
|
||||
@ -131,33 +132,33 @@ namespace __gnu_norm
|
||||
erase(iterator __first, iterator __last)
|
||||
{
|
||||
if (__first == this->_M_start && __last == this->_M_finish)
|
||||
{
|
||||
clear();
|
||||
return this->_M_finish;
|
||||
}
|
||||
{
|
||||
clear();
|
||||
return this->_M_finish;
|
||||
}
|
||||
else
|
||||
{
|
||||
difference_type __n = __last - __first;
|
||||
difference_type __elems_before = __first - this->_M_start;
|
||||
if (static_cast<size_type>(__elems_before) < (size() - __n) / 2)
|
||||
{
|
||||
std::copy_backward(this->_M_start, __first, __last);
|
||||
iterator __new_start = this->_M_start + __n;
|
||||
std::_Destroy(this->_M_start, __new_start);
|
||||
_M_destroy_nodes(this->_M_start._M_node, __new_start._M_node);
|
||||
this->_M_start = __new_start;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::copy(__last, this->_M_finish, __first);
|
||||
iterator __new_finish = this->_M_finish - __n;
|
||||
std::_Destroy(__new_finish, this->_M_finish);
|
||||
_M_destroy_nodes(__new_finish._M_node + 1,
|
||||
this->_M_finish._M_node + 1);
|
||||
this->_M_finish = __new_finish;
|
||||
}
|
||||
return this->_M_start + __elems_before;
|
||||
}
|
||||
{
|
||||
const difference_type __n = __last - __first;
|
||||
const difference_type __elems_before = __first - this->_M_start;
|
||||
if (static_cast<size_type>(__elems_before) < (size() - __n) / 2)
|
||||
{
|
||||
std::copy_backward(this->_M_start, __first, __last);
|
||||
iterator __new_start = this->_M_start + __n;
|
||||
std::_Destroy(this->_M_start, __new_start);
|
||||
_M_destroy_nodes(this->_M_start._M_node, __new_start._M_node);
|
||||
this->_M_start = __new_start;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::copy(__last, this->_M_finish, __first);
|
||||
iterator __new_finish = this->_M_finish - __n;
|
||||
std::_Destroy(__new_finish, this->_M_finish);
|
||||
_M_destroy_nodes(__new_finish._M_node + 1,
|
||||
this->_M_finish._M_node + 1);
|
||||
this->_M_finish = __new_finish;
|
||||
}
|
||||
return this->_M_start + __elems_before;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename _Tp, typename _Alloc>
|
||||
@ -168,20 +169,20 @@ namespace __gnu_norm
|
||||
for (_Map_pointer __node = this->_M_start._M_node + 1;
|
||||
__node < this->_M_finish._M_node;
|
||||
++__node)
|
||||
{
|
||||
std::_Destroy(*__node, *__node + _S_buffer_size());
|
||||
_M_deallocate_node(*__node);
|
||||
}
|
||||
{
|
||||
std::_Destroy(*__node, *__node + _S_buffer_size());
|
||||
_M_deallocate_node(*__node);
|
||||
}
|
||||
|
||||
if (this->_M_start._M_node != this->_M_finish._M_node)
|
||||
{
|
||||
std::_Destroy(this->_M_start._M_cur, this->_M_start._M_last);
|
||||
std::_Destroy(this->_M_finish._M_first, this->_M_finish._M_cur);
|
||||
_M_deallocate_node(this->_M_finish._M_first);
|
||||
}
|
||||
{
|
||||
std::_Destroy(this->_M_start._M_cur, this->_M_start._M_last);
|
||||
std::_Destroy(this->_M_finish._M_first, this->_M_finish._M_cur);
|
||||
_M_deallocate_node(this->_M_finish._M_first);
|
||||
}
|
||||
else
|
||||
std::_Destroy(this->_M_start._M_cur, this->_M_finish._M_cur);
|
||||
|
||||
|
||||
this->_M_finish = this->_M_start;
|
||||
}
|
||||
|
||||
@ -189,7 +190,8 @@ namespace __gnu_norm
|
||||
template <typename _InputIterator>
|
||||
void
|
||||
deque<_Tp,_Alloc>
|
||||
::_M_assign_aux(_InputIterator __first, _InputIterator __last, input_iterator_tag)
|
||||
::_M_assign_aux(_InputIterator __first, _InputIterator __last,
|
||||
input_iterator_tag)
|
||||
{
|
||||
iterator __cur = begin();
|
||||
for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
|
||||
@ -206,34 +208,34 @@ namespace __gnu_norm
|
||||
_M_fill_insert(iterator __pos, size_type __n, const value_type& __x)
|
||||
{
|
||||
if (__pos._M_cur == this->_M_start._M_cur)
|
||||
{
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
try
|
||||
{
|
||||
std::uninitialized_fill(__new_start, this->_M_start, __x);
|
||||
this->_M_start = __new_start;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
{
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
try
|
||||
{
|
||||
std::uninitialized_fill(__new_start, this->_M_start, __x);
|
||||
this->_M_start = __new_start;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
else if (__pos._M_cur == this->_M_finish._M_cur)
|
||||
{
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
try
|
||||
{
|
||||
std::uninitialized_fill(this->_M_finish, __new_finish, __x);
|
||||
this->_M_finish = __new_finish;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_M_destroy_nodes(this->_M_finish._M_node + 1,
|
||||
__new_finish._M_node + 1);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
{
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
try
|
||||
{
|
||||
std::uninitialized_fill(this->_M_finish, __new_finish, __x);
|
||||
this->_M_finish = __new_finish;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_M_destroy_nodes(this->_M_finish._M_node + 1,
|
||||
__new_finish._M_node + 1);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
else
|
||||
_M_insert_aux(__pos, __n, __x);
|
||||
}
|
||||
@ -288,7 +290,7 @@ namespace __gnu_norm
|
||||
_M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
|
||||
forward_iterator_tag)
|
||||
{
|
||||
size_type __n = std::distance(__first, __last);
|
||||
const size_type __n = std::distance(__first, __last);
|
||||
this->_M_initialize_map(__n);
|
||||
|
||||
_Map_pointer __cur_node;
|
||||
@ -389,9 +391,7 @@ namespace __gnu_norm
|
||||
_M_range_insert_aux(iterator __pos,
|
||||
_InputIterator __first, _InputIterator __last,
|
||||
input_iterator_tag)
|
||||
{
|
||||
std::copy(__first, __last, std::inserter(*this, __pos));
|
||||
}
|
||||
{ std::copy(__first, __last, std::inserter(*this, __pos)); }
|
||||
|
||||
template <typename _Tp, typename _Alloc>
|
||||
template <typename _ForwardIterator>
|
||||
@ -403,34 +403,34 @@ namespace __gnu_norm
|
||||
{
|
||||
size_type __n = std::distance(__first, __last);
|
||||
if (__pos._M_cur == this->_M_start._M_cur)
|
||||
{
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
try
|
||||
{
|
||||
std::uninitialized_copy(__first, __last, __new_start);
|
||||
this->_M_start = __new_start;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
{
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
try
|
||||
{
|
||||
std::uninitialized_copy(__first, __last, __new_start);
|
||||
this->_M_start = __new_start;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
else if (__pos._M_cur == this->_M_finish._M_cur)
|
||||
{
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
try
|
||||
{
|
||||
std::uninitialized_copy(__first, __last, this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_M_destroy_nodes(this->_M_finish._M_node + 1,
|
||||
__new_finish._M_node + 1);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
{
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
try
|
||||
{
|
||||
std::uninitialized_copy(__first, __last, this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_M_destroy_nodes(this->_M_finish._M_node + 1,
|
||||
__new_finish._M_node + 1);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
else
|
||||
_M_insert_aux(__pos, __first, __last, __n);
|
||||
}
|
||||
@ -443,27 +443,27 @@ namespace __gnu_norm
|
||||
difference_type __index = __pos - this->_M_start;
|
||||
value_type __x_copy = __x; // XXX copy
|
||||
if (static_cast<size_type>(__index) < size() / 2)
|
||||
{
|
||||
push_front(front());
|
||||
iterator __front1 = this->_M_start;
|
||||
++__front1;
|
||||
iterator __front2 = __front1;
|
||||
++__front2;
|
||||
__pos = this->_M_start + __index;
|
||||
iterator __pos1 = __pos;
|
||||
++__pos1;
|
||||
std::copy(__front2, __pos1, __front1);
|
||||
}
|
||||
{
|
||||
push_front(front());
|
||||
iterator __front1 = this->_M_start;
|
||||
++__front1;
|
||||
iterator __front2 = __front1;
|
||||
++__front2;
|
||||
__pos = this->_M_start + __index;
|
||||
iterator __pos1 = __pos;
|
||||
++__pos1;
|
||||
std::copy(__front2, __pos1, __front1);
|
||||
}
|
||||
else
|
||||
{
|
||||
push_back(back());
|
||||
iterator __back1 = this->_M_finish;
|
||||
--__back1;
|
||||
iterator __back2 = __back1;
|
||||
--__back2;
|
||||
__pos = this->_M_start + __index;
|
||||
std::copy_backward(__pos, __back2, __back1);
|
||||
}
|
||||
{
|
||||
push_back(back());
|
||||
iterator __back1 = this->_M_finish;
|
||||
--__back1;
|
||||
iterator __back2 = __back1;
|
||||
--__back2;
|
||||
__pos = this->_M_start + __index;
|
||||
std::copy_backward(__pos, __back2, __back1);
|
||||
}
|
||||
*__pos = __x_copy;
|
||||
return __pos;
|
||||
}
|
||||
@ -477,69 +477,73 @@ namespace __gnu_norm
|
||||
size_type __length = this->size();
|
||||
value_type __x_copy = __x;
|
||||
if (__elems_before < difference_type(__length / 2))
|
||||
{
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
iterator __old_start = this->_M_start;
|
||||
__pos = this->_M_start + __elems_before;
|
||||
try
|
||||
{
|
||||
if (__elems_before >= difference_type(__n))
|
||||
{
|
||||
iterator __start_n = this->_M_start + difference_type(__n);
|
||||
std::uninitialized_copy(this->_M_start, __start_n, __new_start);
|
||||
this->_M_start = __new_start;
|
||||
std::copy(__start_n, __pos, __old_start);
|
||||
fill(__pos - difference_type(__n), __pos, __x_copy);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::__uninitialized_copy_fill(this->_M_start, __pos, __new_start,
|
||||
this->_M_start, __x_copy);
|
||||
this->_M_start = __new_start;
|
||||
std::fill(__old_start, __pos, __x_copy);
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
{
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
iterator __old_start = this->_M_start;
|
||||
__pos = this->_M_start + __elems_before;
|
||||
try
|
||||
{
|
||||
if (__elems_before >= difference_type(__n))
|
||||
{
|
||||
iterator __start_n = this->_M_start + difference_type(__n);
|
||||
std::uninitialized_copy(this->_M_start, __start_n,
|
||||
__new_start);
|
||||
this->_M_start = __new_start;
|
||||
std::copy(__start_n, __pos, __old_start);
|
||||
fill(__pos - difference_type(__n), __pos, __x_copy);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::__uninitialized_copy_fill(this->_M_start, __pos,
|
||||
__new_start,
|
||||
this->_M_start, __x_copy);
|
||||
this->_M_start = __new_start;
|
||||
std::fill(__old_start, __pos, __x_copy);
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
iterator __old_finish = this->_M_finish;
|
||||
const difference_type __elems_after =
|
||||
difference_type(__length) - __elems_before;
|
||||
__pos = this->_M_finish - __elems_after;
|
||||
try
|
||||
{
|
||||
if (__elems_after > difference_type(__n))
|
||||
{
|
||||
iterator __finish_n = this->_M_finish - difference_type(__n);
|
||||
std::uninitialized_copy(__finish_n, this->_M_finish, this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
std::copy_backward(__pos, __finish_n, __old_finish);
|
||||
std::fill(__pos, __pos + difference_type(__n), __x_copy);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::__uninitialized_fill_copy(this->_M_finish,
|
||||
__pos + difference_type(__n),
|
||||
__x_copy, __pos, this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
std::fill(__pos, __old_finish, __x_copy);
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_M_destroy_nodes(this->_M_finish._M_node + 1,
|
||||
__new_finish._M_node + 1);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
{
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
iterator __old_finish = this->_M_finish;
|
||||
const difference_type __elems_after =
|
||||
difference_type(__length) - __elems_before;
|
||||
__pos = this->_M_finish - __elems_after;
|
||||
try
|
||||
{
|
||||
if (__elems_after > difference_type(__n))
|
||||
{
|
||||
iterator __finish_n = this->_M_finish - difference_type(__n);
|
||||
std::uninitialized_copy(__finish_n, this->_M_finish,
|
||||
this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
std::copy_backward(__pos, __finish_n, __old_finish);
|
||||
std::fill(__pos, __pos + difference_type(__n), __x_copy);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::__uninitialized_fill_copy(this->_M_finish,
|
||||
__pos + difference_type(__n),
|
||||
__x_copy, __pos,
|
||||
this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
std::fill(__pos, __old_finish, __x_copy);
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_M_destroy_nodes(this->_M_finish._M_node + 1,
|
||||
__new_finish._M_node + 1);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename _Tp, typename _Alloc>
|
||||
template <typename _ForwardIterator>
|
||||
void
|
||||
@ -551,36 +555,37 @@ namespace __gnu_norm
|
||||
const difference_type __elemsbefore = __pos - this->_M_start;
|
||||
size_type __length = size();
|
||||
if (static_cast<size_type>(__elemsbefore) < __length / 2)
|
||||
{
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
iterator __old_start = this->_M_start;
|
||||
__pos = this->_M_start + __elemsbefore;
|
||||
try
|
||||
{
|
||||
if (__elemsbefore >= difference_type(__n))
|
||||
{
|
||||
iterator __start_n = this->_M_start + difference_type(__n);
|
||||
std::uninitialized_copy(this->_M_start, __start_n, __new_start);
|
||||
this->_M_start = __new_start;
|
||||
std::copy(__start_n, __pos, __old_start);
|
||||
std::copy(__first, __last, __pos - difference_type(__n));
|
||||
}
|
||||
else
|
||||
{
|
||||
_ForwardIterator __mid = __first;
|
||||
std::advance(__mid, difference_type(__n) - __elemsbefore);
|
||||
std::__uninitialized_copy_copy(this->_M_start, __pos,
|
||||
__first, __mid, __new_start);
|
||||
this->_M_start = __new_start;
|
||||
std::copy(__mid, __last, __old_start);
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
{
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
iterator __old_start = this->_M_start;
|
||||
__pos = this->_M_start + __elemsbefore;
|
||||
try
|
||||
{
|
||||
if (__elemsbefore >= difference_type(__n))
|
||||
{
|
||||
iterator __start_n = this->_M_start + difference_type(__n);
|
||||
std::uninitialized_copy(this->_M_start, __start_n,
|
||||
__new_start);
|
||||
this->_M_start = __new_start;
|
||||
std::copy(__start_n, __pos, __old_start);
|
||||
std::copy(__first, __last, __pos - difference_type(__n));
|
||||
}
|
||||
else
|
||||
{
|
||||
_ForwardIterator __mid = __first;
|
||||
std::advance(__mid, difference_type(__n) - __elemsbefore);
|
||||
std::__uninitialized_copy_copy(this->_M_start, __pos,
|
||||
__first, __mid, __new_start);
|
||||
this->_M_start = __new_start;
|
||||
std::copy(__mid, __last, __old_start);
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
@ -591,24 +596,25 @@ namespace __gnu_norm
|
||||
try
|
||||
{
|
||||
if (__elemsafter > difference_type(__n))
|
||||
{
|
||||
iterator __finish_n = this->_M_finish - difference_type(__n);
|
||||
std::uninitialized_copy(__finish_n,
|
||||
this->_M_finish,
|
||||
this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
std::copy_backward(__pos, __finish_n, __old_finish);
|
||||
std::copy(__first, __last, __pos);
|
||||
}
|
||||
{
|
||||
iterator __finish_n = this->_M_finish - difference_type(__n);
|
||||
std::uninitialized_copy(__finish_n,
|
||||
this->_M_finish,
|
||||
this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
std::copy_backward(__pos, __finish_n, __old_finish);
|
||||
std::copy(__first, __last, __pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ForwardIterator __mid = __first;
|
||||
std::advance(__mid, __elemsafter);
|
||||
std::__uninitialized_copy_copy(__mid, __last, __pos,
|
||||
this->_M_finish, this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
std::copy(__first, __mid, __pos);
|
||||
}
|
||||
{
|
||||
_ForwardIterator __mid = __first;
|
||||
std::advance(__mid, __elemsafter);
|
||||
std::__uninitialized_copy_copy(__mid, __last, __pos,
|
||||
this->_M_finish,
|
||||
this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
std::copy(__first, __mid, __pos);
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -625,7 +631,7 @@ namespace __gnu_norm
|
||||
_M_new_elements_at_front(size_type __new_elems)
|
||||
{
|
||||
size_type __new_nodes
|
||||
= (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();
|
||||
= (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();
|
||||
_M_reserve_map_at_front(__new_nodes);
|
||||
size_type __i;
|
||||
try
|
||||
@ -674,39 +680,40 @@ namespace __gnu_norm
|
||||
|
||||
_Map_pointer __new_nstart;
|
||||
if (this->_M_map_size > 2 * __new_num_nodes)
|
||||
{
|
||||
__new_nstart
|
||||
= this->_M_map + (this->_M_map_size - __new_num_nodes) / 2
|
||||
+ (__add_at_front ? __nodes_to_add : 0);
|
||||
if (__new_nstart < this->_M_start._M_node)
|
||||
std::copy(this->_M_start._M_node,
|
||||
{
|
||||
__new_nstart = this->_M_map + (this->_M_map_size
|
||||
- __new_num_nodes) / 2
|
||||
+ (__add_at_front ? __nodes_to_add : 0);
|
||||
if (__new_nstart < this->_M_start._M_node)
|
||||
std::copy(this->_M_start._M_node,
|
||||
this->_M_finish._M_node + 1,
|
||||
__new_nstart);
|
||||
else
|
||||
std::copy_backward(this->_M_start._M_node,
|
||||
this->_M_finish._M_node + 1,
|
||||
__new_nstart + __old_num_nodes);
|
||||
}
|
||||
else
|
||||
std::copy_backward(this->_M_start._M_node,
|
||||
this->_M_finish._M_node + 1,
|
||||
__new_nstart + __old_num_nodes);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_type __new_map_size =
|
||||
this->_M_map_size + std::max(this->_M_map_size, __nodes_to_add) + 2;
|
||||
|
||||
_Map_pointer __new_map = this->_M_allocate_map(__new_map_size);
|
||||
__new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2
|
||||
+ (__add_at_front ? __nodes_to_add : 0);
|
||||
std::copy(this->_M_start._M_node,
|
||||
this->_M_finish._M_node + 1,
|
||||
__new_nstart);
|
||||
_M_deallocate_map(this->_M_map, this->_M_map_size);
|
||||
|
||||
this->_M_map = __new_map;
|
||||
this->_M_map_size = __new_map_size;
|
||||
}
|
||||
{
|
||||
size_type __new_map_size = this->_M_map_size
|
||||
+ std::max(this->_M_map_size,
|
||||
__nodes_to_add) + 2;
|
||||
|
||||
_Map_pointer __new_map = this->_M_allocate_map(__new_map_size);
|
||||
__new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2
|
||||
+ (__add_at_front ? __nodes_to_add : 0);
|
||||
std::copy(this->_M_start._M_node,
|
||||
this->_M_finish._M_node + 1,
|
||||
__new_nstart);
|
||||
_M_deallocate_map(this->_M_map, this->_M_map_size);
|
||||
|
||||
this->_M_map = __new_map;
|
||||
this->_M_map_size = __new_map_size;
|
||||
}
|
||||
|
||||
this->_M_start._M_set_node(__new_nstart);
|
||||
this->_M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
|
||||
}
|
||||
} // namespace __gnu_norm
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
// List implementation (out of line) -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -120,18 +120,18 @@ namespace __gnu_norm
|
||||
operator=(const list& __x)
|
||||
{
|
||||
if (this != &__x)
|
||||
{
|
||||
iterator __first1 = begin();
|
||||
iterator __last1 = end();
|
||||
const_iterator __first2 = __x.begin();
|
||||
const_iterator __last2 = __x.end();
|
||||
while (__first1 != __last1 && __first2 != __last2)
|
||||
*__first1++ = *__first2++;
|
||||
if (__first2 == __last2)
|
||||
erase(__first1, __last1);
|
||||
else
|
||||
insert(__last1, __first2, __last2);
|
||||
}
|
||||
{
|
||||
iterator __first1 = begin();
|
||||
iterator __last1 = end();
|
||||
const_iterator __first2 = __x.begin();
|
||||
const_iterator __last2 = __x.end();
|
||||
while (__first1 != __last1 && __first2 != __last2)
|
||||
*__first1++ = *__first2++;
|
||||
if (__first2 == __last2)
|
||||
erase(__first1, __last1);
|
||||
else
|
||||
insert(__last1, __first2, __last2);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -191,7 +191,8 @@ namespace __gnu_norm
|
||||
{
|
||||
iterator __first = begin();
|
||||
iterator __last = end();
|
||||
if (__first == __last) return;
|
||||
if (__first == __last)
|
||||
return;
|
||||
iterator __next = __first;
|
||||
while (++__next != __last)
|
||||
{
|
||||
@ -245,19 +246,21 @@ namespace __gnu_norm
|
||||
list * __counter;
|
||||
|
||||
do
|
||||
{
|
||||
__carry.splice(__carry.begin(), *this, begin());
|
||||
|
||||
for(__counter = &__tmp[0];
|
||||
(__counter != __fill) && !__counter->empty();
|
||||
++__counter)
|
||||
{
|
||||
__counter->merge(__carry);
|
||||
__carry.swap(*__counter);
|
||||
}
|
||||
__carry.swap(*__counter);
|
||||
if (__counter == __fill) ++__fill;
|
||||
} while ( !empty() );
|
||||
{
|
||||
__carry.splice(__carry.begin(), *this, begin());
|
||||
|
||||
for(__counter = &__tmp[0];
|
||||
(__counter != __fill) && !__counter->empty();
|
||||
++__counter)
|
||||
{
|
||||
__counter->merge(__carry);
|
||||
__carry.swap(*__counter);
|
||||
}
|
||||
__carry.swap(*__counter);
|
||||
if (__counter == __fill)
|
||||
++__fill;
|
||||
}
|
||||
while ( !empty() );
|
||||
|
||||
for (__counter = &__tmp[1]; __counter != __fill; ++__counter)
|
||||
__counter->merge( *(__counter-1) );
|
||||
@ -277,7 +280,8 @@ namespace __gnu_norm
|
||||
{
|
||||
iterator __next = __first;
|
||||
++__next;
|
||||
if (__pred(*__first)) _M_erase(__first);
|
||||
if (__pred(*__first))
|
||||
_M_erase(__first);
|
||||
__first = __next;
|
||||
}
|
||||
}
|
||||
@ -332,39 +336,41 @@ namespace __gnu_norm
|
||||
|
||||
template<typename _Tp, typename _Alloc>
|
||||
template <typename _StrictWeakOrdering>
|
||||
void
|
||||
list<_Tp,_Alloc>::
|
||||
sort(_StrictWeakOrdering __comp)
|
||||
{
|
||||
// Do nothing if the list has length 0 or 1.
|
||||
if (this->_M_node._M_next != &this->_M_node &&
|
||||
this->_M_node._M_next->_M_next != &this->_M_node)
|
||||
void
|
||||
list<_Tp,_Alloc>::
|
||||
sort(_StrictWeakOrdering __comp)
|
||||
{
|
||||
list __carry;
|
||||
list __tmp[64];
|
||||
list * __fill = &__tmp[0];
|
||||
list * __counter;
|
||||
|
||||
do
|
||||
{
|
||||
__carry.splice(__carry.begin(), *this, begin());
|
||||
|
||||
for(__counter = &__tmp[0];
|
||||
(__counter != __fill) && !__counter->empty();
|
||||
++__counter)
|
||||
{
|
||||
__counter->merge(__carry, __comp);
|
||||
__carry.swap(*__counter);
|
||||
}
|
||||
__carry.swap(*__counter);
|
||||
if (__counter == __fill) ++__fill;
|
||||
} while ( !empty() );
|
||||
|
||||
for (__counter = &__tmp[1]; __counter != __fill; ++__counter)
|
||||
__counter->merge( *(__counter-1), __comp );
|
||||
swap( *(__fill-1) );
|
||||
// Do nothing if the list has length 0 or 1.
|
||||
if (this->_M_node._M_next != &this->_M_node
|
||||
&& this->_M_node._M_next->_M_next != &this->_M_node)
|
||||
{
|
||||
list __carry;
|
||||
list __tmp[64];
|
||||
list * __fill = &__tmp[0];
|
||||
list * __counter;
|
||||
|
||||
do
|
||||
{
|
||||
__carry.splice(__carry.begin(), *this, begin());
|
||||
|
||||
for(__counter = &__tmp[0];
|
||||
(__counter != __fill) && !__counter->empty();
|
||||
++__counter)
|
||||
{
|
||||
__counter->merge(__carry, __comp);
|
||||
__carry.swap(*__counter);
|
||||
}
|
||||
__carry.swap(*__counter);
|
||||
if (__counter == __fill)
|
||||
++__fill;
|
||||
}
|
||||
while ( !empty() );
|
||||
|
||||
for (__counter = &__tmp[1]; __counter != __fill; ++__counter)
|
||||
__counter->merge( *(__counter-1), __comp );
|
||||
swap( *(__fill-1) );
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace __gnu_norm
|
||||
|
||||
#endif /* _LIST_TCC */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
// Iterators -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -137,7 +137,8 @@ namespace std
|
||||
* @return @c current, the %iterator used for underlying work.
|
||||
*/
|
||||
iterator_type
|
||||
base() const { return current; }
|
||||
base() const
|
||||
{ return current; }
|
||||
|
||||
/**
|
||||
* @return TODO
|
||||
@ -157,7 +158,8 @@ namespace std
|
||||
* @doctodo
|
||||
*/
|
||||
pointer
|
||||
operator->() const { return &(operator*()); }
|
||||
operator->() const
|
||||
{ return &(operator*()); }
|
||||
|
||||
/**
|
||||
* @return TODO
|
||||
@ -256,7 +258,8 @@ namespace std
|
||||
* @doctodo
|
||||
*/
|
||||
reference
|
||||
operator[](difference_type __n) const { return *(*this + __n); }
|
||||
operator[](difference_type __n) const
|
||||
{ return *(*this + __n); }
|
||||
};
|
||||
|
||||
//@{
|
||||
@ -364,15 +367,18 @@ namespace std
|
||||
|
||||
/// Simply returns *this.
|
||||
back_insert_iterator&
|
||||
operator*() { return *this; }
|
||||
operator*()
|
||||
{ return *this; }
|
||||
|
||||
/// Simply returns *this. (This %iterator does not "move".)
|
||||
back_insert_iterator&
|
||||
operator++() { return *this; }
|
||||
operator++()
|
||||
{ return *this; }
|
||||
|
||||
/// Simply returns *this. (This %iterator does not "move".)
|
||||
back_insert_iterator
|
||||
operator++(int) { return *this; }
|
||||
operator++(int)
|
||||
{ return *this; }
|
||||
};
|
||||
|
||||
/**
|
||||
@ -435,15 +441,18 @@ namespace std
|
||||
|
||||
/// Simply returns *this.
|
||||
front_insert_iterator&
|
||||
operator*() { return *this; }
|
||||
operator*()
|
||||
{ return *this; }
|
||||
|
||||
/// Simply returns *this. (This %iterator does not "move".)
|
||||
front_insert_iterator&
|
||||
operator++() { return *this; }
|
||||
operator++()
|
||||
{ return *this; }
|
||||
|
||||
/// Simply returns *this. (This %iterator does not "move".)
|
||||
front_insert_iterator
|
||||
operator++(int) { return *this; }
|
||||
operator++(int)
|
||||
{ return *this; }
|
||||
};
|
||||
|
||||
/**
|
||||
@ -528,15 +537,18 @@ namespace std
|
||||
|
||||
/// Simply returns *this.
|
||||
insert_iterator&
|
||||
operator*() { return *this; }
|
||||
operator*()
|
||||
{ return *this; }
|
||||
|
||||
/// Simply returns *this. (This %iterator does not "move".)
|
||||
insert_iterator&
|
||||
operator++() { return *this; }
|
||||
operator++()
|
||||
{ return *this; }
|
||||
|
||||
/// Simply returns *this. (This %iterator does not "move".)
|
||||
insert_iterator&
|
||||
operator++(int) { return *this; }
|
||||
operator++(int)
|
||||
{ return *this; }
|
||||
};
|
||||
|
||||
/**
|
||||
@ -578,12 +590,12 @@ namespace __gnu_cxx
|
||||
|
||||
public:
|
||||
typedef typename iterator_traits<_Iterator>::iterator_category
|
||||
iterator_category;
|
||||
iterator_category;
|
||||
typedef typename iterator_traits<_Iterator>::value_type value_type;
|
||||
typedef typename iterator_traits<_Iterator>::difference_type
|
||||
difference_type;
|
||||
typedef typename iterator_traits<_Iterator>::reference reference;
|
||||
typedef typename iterator_traits<_Iterator>::pointer pointer;
|
||||
difference_type;
|
||||
typedef typename iterator_traits<_Iterator>::reference reference;
|
||||
typedef typename iterator_traits<_Iterator>::pointer pointer;
|
||||
|
||||
__normal_iterator() : _M_current(_Iterator()) { }
|
||||
|
||||
@ -592,28 +604,41 @@ namespace __gnu_cxx
|
||||
|
||||
// Allow iterator to const_iterator conversion
|
||||
template<typename _Iter>
|
||||
inline __normal_iterator(const __normal_iterator<_Iter, _Container>& __i)
|
||||
inline __normal_iterator(const __normal_iterator<_Iter,
|
||||
_Container>& __i)
|
||||
: _M_current(__i.base()) { }
|
||||
|
||||
// Forward iterator requirements
|
||||
reference
|
||||
operator*() const { return *_M_current; }
|
||||
operator*() const
|
||||
{ return *_M_current; }
|
||||
|
||||
pointer
|
||||
operator->() const { return _M_current; }
|
||||
operator->() const
|
||||
{ return _M_current; }
|
||||
|
||||
__normal_iterator&
|
||||
operator++() { ++_M_current; return *this; }
|
||||
operator++()
|
||||
{
|
||||
++_M_current;
|
||||
return *this;
|
||||
}
|
||||
|
||||
__normal_iterator
|
||||
operator++(int) { return __normal_iterator(_M_current++); }
|
||||
operator++(int)
|
||||
{ return __normal_iterator(_M_current++); }
|
||||
|
||||
// Bidirectional iterator requirements
|
||||
__normal_iterator&
|
||||
operator--() { --_M_current; return *this; }
|
||||
operator--()
|
||||
{
|
||||
--_M_current;
|
||||
return *this;
|
||||
}
|
||||
|
||||
__normal_iterator
|
||||
operator--(int) { return __normal_iterator(_M_current--); }
|
||||
operator--(int)
|
||||
{ return __normal_iterator(_M_current--); }
|
||||
|
||||
// Random access iterator requirements
|
||||
reference
|
||||
@ -637,7 +662,8 @@ namespace __gnu_cxx
|
||||
{ return __normal_iterator(_M_current - __n); }
|
||||
|
||||
const _Iterator&
|
||||
base() const { return _M_current; }
|
||||
base() const
|
||||
{ return _M_current; }
|
||||
};
|
||||
|
||||
// Note: In what follows, the left- and right-hand-side iterators are
|
||||
@ -650,93 +676,93 @@ namespace __gnu_cxx
|
||||
|
||||
// Forward iterator requirements
|
||||
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
||||
inline bool
|
||||
operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
||||
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
||||
{ return __lhs.base() == __rhs.base(); }
|
||||
inline bool
|
||||
operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
||||
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
||||
{ return __lhs.base() == __rhs.base(); }
|
||||
|
||||
template<typename _Iterator, typename _Container>
|
||||
inline bool
|
||||
operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
|
||||
const __normal_iterator<_Iterator, _Container>& __rhs)
|
||||
{ return __lhs.base() == __rhs.base(); }
|
||||
inline bool
|
||||
operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
|
||||
const __normal_iterator<_Iterator, _Container>& __rhs)
|
||||
{ return __lhs.base() == __rhs.base(); }
|
||||
|
||||
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
||||
inline bool
|
||||
operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
||||
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
||||
{ return __lhs.base() != __rhs.base(); }
|
||||
inline bool
|
||||
operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
||||
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
||||
{ return __lhs.base() != __rhs.base(); }
|
||||
|
||||
template<typename _Iterator, typename _Container>
|
||||
inline bool
|
||||
operator!=(const __normal_iterator<_Iterator, _Container>& __lhs,
|
||||
const __normal_iterator<_Iterator, _Container>& __rhs)
|
||||
{ return __lhs.base() != __rhs.base(); }
|
||||
inline bool
|
||||
operator!=(const __normal_iterator<_Iterator, _Container>& __lhs,
|
||||
const __normal_iterator<_Iterator, _Container>& __rhs)
|
||||
{ return __lhs.base() != __rhs.base(); }
|
||||
|
||||
// Random access iterator requirements
|
||||
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
||||
inline bool
|
||||
operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
||||
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
||||
{ return __lhs.base() < __rhs.base(); }
|
||||
inline bool
|
||||
operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
||||
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
||||
{ return __lhs.base() < __rhs.base(); }
|
||||
|
||||
template<typename _Iterator, typename _Container>
|
||||
inline bool
|
||||
operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
|
||||
const __normal_iterator<_Iterator, _Container>& __rhs)
|
||||
{ return __lhs.base() < __rhs.base(); }
|
||||
inline bool
|
||||
operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
|
||||
const __normal_iterator<_Iterator, _Container>& __rhs)
|
||||
{ return __lhs.base() < __rhs.base(); }
|
||||
|
||||
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
||||
inline bool
|
||||
operator>(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
||||
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
||||
{ return __lhs.base() > __rhs.base(); }
|
||||
inline bool
|
||||
operator>(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
||||
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
||||
{ return __lhs.base() > __rhs.base(); }
|
||||
|
||||
template<typename _Iterator, typename _Container>
|
||||
inline bool
|
||||
operator>(const __normal_iterator<_Iterator, _Container>& __lhs,
|
||||
const __normal_iterator<_Iterator, _Container>& __rhs)
|
||||
{ return __lhs.base() > __rhs.base(); }
|
||||
inline bool
|
||||
operator>(const __normal_iterator<_Iterator, _Container>& __lhs,
|
||||
const __normal_iterator<_Iterator, _Container>& __rhs)
|
||||
{ return __lhs.base() > __rhs.base(); }
|
||||
|
||||
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
||||
inline bool
|
||||
operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
||||
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
||||
{ return __lhs.base() <= __rhs.base(); }
|
||||
inline bool
|
||||
operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
||||
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
||||
{ return __lhs.base() <= __rhs.base(); }
|
||||
|
||||
template<typename _Iterator, typename _Container>
|
||||
inline bool
|
||||
operator<=(const __normal_iterator<_Iterator, _Container>& __lhs,
|
||||
const __normal_iterator<_Iterator, _Container>& __rhs)
|
||||
{ return __lhs.base() <= __rhs.base(); }
|
||||
inline bool
|
||||
operator<=(const __normal_iterator<_Iterator, _Container>& __lhs,
|
||||
const __normal_iterator<_Iterator, _Container>& __rhs)
|
||||
{ return __lhs.base() <= __rhs.base(); }
|
||||
|
||||
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
||||
inline bool
|
||||
operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
||||
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
||||
{ return __lhs.base() >= __rhs.base(); }
|
||||
inline bool
|
||||
operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
||||
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
||||
{ return __lhs.base() >= __rhs.base(); }
|
||||
|
||||
template<typename _Iterator, typename _Container>
|
||||
inline bool
|
||||
operator>=(const __normal_iterator<_Iterator, _Container>& __lhs,
|
||||
const __normal_iterator<_Iterator, _Container>& __rhs)
|
||||
{ return __lhs.base() >= __rhs.base(); }
|
||||
inline bool
|
||||
operator>=(const __normal_iterator<_Iterator, _Container>& __lhs,
|
||||
const __normal_iterator<_Iterator, _Container>& __rhs)
|
||||
{ return __lhs.base() >= __rhs.base(); }
|
||||
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// According to the resolution of DR179 not only the various comparison
|
||||
// operators but also operator- must accept mixed iterator/const_iterator
|
||||
// parameters.
|
||||
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
||||
inline typename __normal_iterator<_IteratorL, _Container>::difference_type
|
||||
operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
||||
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
||||
{ return __lhs.base() - __rhs.base(); }
|
||||
inline typename __normal_iterator<_IteratorL, _Container>::difference_type
|
||||
operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
||||
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
||||
{ return __lhs.base() - __rhs.base(); }
|
||||
|
||||
template<typename _Iterator, typename _Container>
|
||||
inline __normal_iterator<_Iterator, _Container>
|
||||
operator+(typename __normal_iterator<_Iterator, _Container>::difference_type __n,
|
||||
const __normal_iterator<_Iterator, _Container>& __i)
|
||||
{ return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
|
||||
inline __normal_iterator<_Iterator, _Container>
|
||||
operator+(typename __normal_iterator<_Iterator, _Container>::difference_type
|
||||
__n, const __normal_iterator<_Iterator, _Container>& __i)
|
||||
{ return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
|
||||
} // namespace __gnu_cxx
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Functions used by iterators -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -78,9 +78,11 @@ namespace std
|
||||
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
|
||||
|
||||
typename iterator_traits<_InputIterator>::difference_type __n = 0;
|
||||
while (__first != __last) {
|
||||
++__first; ++__n;
|
||||
}
|
||||
while (__first != __last)
|
||||
{
|
||||
++__first;
|
||||
++__n;
|
||||
}
|
||||
return __n;
|
||||
}
|
||||
|
||||
@ -90,7 +92,8 @@ namespace std
|
||||
random_access_iterator_tag)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>)
|
||||
__glibcxx_function_requires(_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>)
|
||||
return __last - __first;
|
||||
}
|
||||
|
||||
@ -111,7 +114,8 @@ namespace std
|
||||
distance(_InputIterator __first, _InputIterator __last)
|
||||
{
|
||||
// concept requirements -- taken care of in __distance
|
||||
return std::__distance(__first, __last, std::__iterator_category(__first));
|
||||
return std::__distance(__first, __last,
|
||||
std::__iterator_category(__first));
|
||||
}
|
||||
|
||||
template<typename _InputIterator, typename _Distance>
|
||||
@ -120,7 +124,8 @@ namespace std
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
|
||||
while (__n--) ++__i;
|
||||
while (__n--)
|
||||
++__i;
|
||||
}
|
||||
|
||||
template<typename _BidirectionalIterator, typename _Distance>
|
||||
@ -129,8 +134,8 @@ namespace std
|
||||
bidirectional_iterator_tag)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_BidirectionalIteratorConcept<_BidirectionalIterator>)
|
||||
|
||||
__glibcxx_function_requires(_BidirectionalIteratorConcept<
|
||||
_BidirectionalIterator>)
|
||||
if (__n > 0)
|
||||
while (__n--) ++__i;
|
||||
else
|
||||
@ -143,7 +148,8 @@ namespace std
|
||||
random_access_iterator_tag)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>)
|
||||
__glibcxx_function_requires(_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>)
|
||||
__i += __n;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Types used in iterator implementation -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -82,9 +82,11 @@ namespace std
|
||||
struct output_iterator_tag {};
|
||||
/// Forward iterators support a superset of input iterator operations.
|
||||
struct forward_iterator_tag : public input_iterator_tag {};
|
||||
/// Bidirectional iterators support a superset of forward iterator operations.
|
||||
/// Bidirectional iterators support a superset of forward iterator
|
||||
/// operations.
|
||||
struct bidirectional_iterator_tag : public forward_iterator_tag {};
|
||||
/// Random-access iterators support a superset of bidirectional iterator operations.
|
||||
/// Random-access iterators support a superset of bidirectional iterator
|
||||
/// operations.
|
||||
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
|
||||
//@}
|
||||
|
||||
|
@ -94,7 +94,6 @@ namespace __gnu_norm
|
||||
_Tp _M_data; ///< User's data.
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief A list::iterator.
|
||||
*
|
||||
@ -325,7 +324,6 @@ namespace __gnu_norm
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief A standard container with linear time access to elements,
|
||||
* and fixed time insertion/deletion at any point in the sequence.
|
||||
@ -573,7 +571,8 @@ namespace __gnu_norm
|
||||
|
||||
/// Get a copy of the memory allocation object.
|
||||
allocator_type
|
||||
get_allocator() const { return _Base::get_allocator(); }
|
||||
get_allocator() const
|
||||
{ return _Base::get_allocator(); }
|
||||
|
||||
// iterators
|
||||
/**
|
||||
@ -581,7 +580,8 @@ namespace __gnu_norm
|
||||
* %list. Iteration is done in ordinary element order.
|
||||
*/
|
||||
iterator
|
||||
begin() { return this->_M_node._M_next; }
|
||||
begin()
|
||||
{ return this->_M_node._M_next; }
|
||||
|
||||
/**
|
||||
* Returns a read-only (constant) iterator that points to the
|
||||
@ -589,7 +589,8 @@ namespace __gnu_norm
|
||||
* element order.
|
||||
*/
|
||||
const_iterator
|
||||
begin() const { return this->_M_node._M_next; }
|
||||
begin() const
|
||||
{ return this->_M_node._M_next; }
|
||||
|
||||
/**
|
||||
* Returns a read/write iterator that points one past the last
|
||||
@ -605,7 +606,8 @@ namespace __gnu_norm
|
||||
* element order.
|
||||
*/
|
||||
const_iterator
|
||||
end() const { return &this->_M_node; }
|
||||
end() const
|
||||
{ return &this->_M_node; }
|
||||
|
||||
/**
|
||||
* Returns a read/write reverse iterator that points to the last
|
||||
@ -613,7 +615,8 @@ namespace __gnu_norm
|
||||
* order.
|
||||
*/
|
||||
reverse_iterator
|
||||
rbegin() { return reverse_iterator(end()); }
|
||||
rbegin()
|
||||
{ return reverse_iterator(end()); }
|
||||
|
||||
/**
|
||||
* Returns a read-only (constant) reverse iterator that points to
|
||||
@ -621,7 +624,8 @@ namespace __gnu_norm
|
||||
* element order.
|
||||
*/
|
||||
const_reverse_iterator
|
||||
rbegin() const { return const_reverse_iterator(end()); }
|
||||
rbegin() const
|
||||
{ return const_reverse_iterator(end()); }
|
||||
|
||||
/**
|
||||
* Returns a read/write reverse iterator that points to one
|
||||
@ -629,7 +633,8 @@ namespace __gnu_norm
|
||||
* reverse element order.
|
||||
*/
|
||||
reverse_iterator
|
||||
rend() { return reverse_iterator(begin()); }
|
||||
rend()
|
||||
{ return reverse_iterator(begin()); }
|
||||
|
||||
/**
|
||||
* Returns a read-only (constant) reverse iterator that points to one
|
||||
@ -646,15 +651,18 @@ namespace __gnu_norm
|
||||
* end().)
|
||||
*/
|
||||
bool
|
||||
empty() const { return this->_M_node._M_next == &this->_M_node; }
|
||||
empty() const
|
||||
{ return this->_M_node._M_next == &this->_M_node; }
|
||||
|
||||
/** Returns the number of elements in the %list. */
|
||||
size_type
|
||||
size() const { return std::distance(begin(), end()); }
|
||||
size() const
|
||||
{ return std::distance(begin(), end()); }
|
||||
|
||||
/** Returns the size() of the largest possible %list. */
|
||||
size_type
|
||||
max_size() const { return size_type(-1); }
|
||||
max_size() const
|
||||
{ return size_type(-1); }
|
||||
|
||||
/**
|
||||
* @brief Resizes the %list to the specified number of elements.
|
||||
@ -679,7 +687,8 @@ namespace __gnu_norm
|
||||
* and new elements are default-constructed.
|
||||
*/
|
||||
void
|
||||
resize(size_type __new_size) { this->resize(__new_size, value_type()); }
|
||||
resize(size_type __new_size)
|
||||
{ this->resize(__new_size, value_type()); }
|
||||
|
||||
// element access
|
||||
/**
|
||||
@ -687,28 +696,32 @@ namespace __gnu_norm
|
||||
* element of the %list.
|
||||
*/
|
||||
reference
|
||||
front() { return *begin(); }
|
||||
front()
|
||||
{ return *begin(); }
|
||||
|
||||
/**
|
||||
* Returns a read-only (constant) reference to the data at the first
|
||||
* element of the %list.
|
||||
*/
|
||||
const_reference
|
||||
front() const { return *begin(); }
|
||||
front() const
|
||||
{ return *begin(); }
|
||||
|
||||
/**
|
||||
* Returns a read/write reference to the data at the last element
|
||||
* of the %list.
|
||||
*/
|
||||
reference
|
||||
back() { return *(--end()); }
|
||||
back()
|
||||
{ return *(--end()); }
|
||||
|
||||
/**
|
||||
* Returns a read-only (constant) reference to the data at the last
|
||||
* element of the %list.
|
||||
*/
|
||||
const_reference
|
||||
back() const { return *(--end()); }
|
||||
back() const
|
||||
{ return *(--end()); }
|
||||
|
||||
// [23.2.2.3] modifiers
|
||||
/**
|
||||
@ -722,7 +735,8 @@ namespace __gnu_norm
|
||||
* references.
|
||||
*/
|
||||
void
|
||||
push_front(const value_type& __x) { this->_M_insert(begin(), __x); }
|
||||
push_front(const value_type& __x)
|
||||
{ this->_M_insert(begin(), __x); }
|
||||
|
||||
/**
|
||||
* @brief Removes first element.
|
||||
@ -737,7 +751,8 @@ namespace __gnu_norm
|
||||
* called.
|
||||
*/
|
||||
void
|
||||
pop_front() { this->_M_erase(begin()); }
|
||||
pop_front()
|
||||
{ this->_M_erase(begin()); }
|
||||
|
||||
/**
|
||||
* @brief Add data to the end of the %list.
|
||||
@ -750,7 +765,8 @@ namespace __gnu_norm
|
||||
* references.
|
||||
*/
|
||||
void
|
||||
push_back(const value_type& __x) { this->_M_insert(end(), __x); }
|
||||
push_back(const value_type& __x)
|
||||
{ this->_M_insert(end(), __x); }
|
||||
|
||||
/**
|
||||
* @brief Removes last element.
|
||||
@ -764,7 +780,8 @@ namespace __gnu_norm
|
||||
* is needed, it should be retrieved before pop_back() is called.
|
||||
*/
|
||||
void
|
||||
pop_back() { this->_M_erase(this->_M_node._M_prev); }
|
||||
pop_back()
|
||||
{ this->_M_erase(this->_M_node._M_prev); }
|
||||
|
||||
/**
|
||||
* @brief Inserts given value into %list before specified iterator.
|
||||
@ -876,7 +893,8 @@ namespace __gnu_norm
|
||||
* function.
|
||||
*/
|
||||
void
|
||||
swap(list& __x) { _List_node_base::swap(this->_M_node,__x._M_node); }
|
||||
swap(list& __x)
|
||||
{ _List_node_base::swap(this->_M_node,__x._M_node); }
|
||||
|
||||
/**
|
||||
* Erases all the elements. Note that this function only erases
|
||||
@ -922,7 +940,8 @@ namespace __gnu_norm
|
||||
{
|
||||
iterator __j = __i;
|
||||
++__j;
|
||||
if (__position == __i || __position == __j) return;
|
||||
if (__position == __i || __position == __j)
|
||||
return;
|
||||
this->_M_transfer(__position, __i, __j);
|
||||
}
|
||||
|
||||
@ -1037,7 +1056,8 @@ namespace __gnu_norm
|
||||
* Reverse the order of elements in the list in linear time.
|
||||
*/
|
||||
void
|
||||
reverse() { this->_M_node.reverse(); }
|
||||
reverse()
|
||||
{ this->_M_node.reverse(); }
|
||||
|
||||
/**
|
||||
* @brief Sort the elements.
|
||||
@ -1118,16 +1138,13 @@ namespace __gnu_norm
|
||||
// Moves the elements from [first,last) before position.
|
||||
void
|
||||
_M_transfer(iterator __position, iterator __first, iterator __last)
|
||||
{
|
||||
__position._M_node->transfer(__first._M_node,__last._M_node);
|
||||
}
|
||||
{ __position._M_node->transfer(__first._M_node,__last._M_node); }
|
||||
|
||||
// Inserts new element at position given and with value given.
|
||||
void
|
||||
_M_insert(iterator __position, const value_type& __x)
|
||||
{
|
||||
_Node* __tmp = _M_create_node(__x);
|
||||
|
||||
__tmp->hook(__position._M_node);
|
||||
}
|
||||
|
||||
@ -1142,7 +1159,6 @@ namespace __gnu_norm
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief List equality comparison.
|
||||
* @param x A %list.
|
||||
@ -1167,7 +1183,7 @@ namespace __gnu_norm
|
||||
{
|
||||
++__i1;
|
||||
++__i2;
|
||||
}
|
||||
}
|
||||
return __i1 == __end1 && __i2 == __end2;
|
||||
}
|
||||
|
||||
@ -1185,10 +1201,8 @@ namespace __gnu_norm
|
||||
template<typename _Tp, typename _Alloc>
|
||||
inline bool
|
||||
operator<(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y)
|
||||
{
|
||||
return std::lexicographical_compare(__x.begin(), __x.end(),
|
||||
__y.begin(), __y.end());
|
||||
}
|
||||
{ return std::lexicographical_compare(__x.begin(), __x.end(),
|
||||
__y.begin(), __y.end()); }
|
||||
|
||||
/// Based on operator==
|
||||
template<typename _Tp, typename _Alloc>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
// Multimap implementation -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -103,466 +103,507 @@ namespace __gnu_norm
|
||||
*/
|
||||
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc>
|
||||
class multimap
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
|
||||
__glibcxx_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept)
|
||||
|
||||
public:
|
||||
typedef _Key key_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<const _Key, _Tp> value_type;
|
||||
typedef _Compare key_compare;
|
||||
|
||||
class value_compare
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
|
||||
__glibcxx_class_requires4(_Compare, bool, _Key, _Key,
|
||||
_BinaryFunctionConcept)
|
||||
|
||||
public:
|
||||
typedef _Key key_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<const _Key, _Tp> value_type;
|
||||
typedef _Compare key_compare;
|
||||
|
||||
class value_compare
|
||||
: public binary_function<value_type, value_type, bool>
|
||||
{
|
||||
friend class multimap<_Key,_Tp,_Compare,_Alloc>;
|
||||
friend class multimap<_Key,_Tp,_Compare,_Alloc>;
|
||||
protected:
|
||||
_Compare comp;
|
||||
value_compare(_Compare __c) : comp(__c) {}
|
||||
_Compare comp;
|
||||
|
||||
value_compare(_Compare __c)
|
||||
: comp(__c) { }
|
||||
|
||||
public:
|
||||
bool operator()(const value_type& __x, const value_type& __y) const
|
||||
{ return comp(__x.first, __y.first); }
|
||||
};
|
||||
bool operator()(const value_type& __x, const value_type& __y) const
|
||||
{ return comp(__x.first, __y.first); }
|
||||
};
|
||||
|
||||
private:
|
||||
/// @if maint This turns a red-black tree into a [multi]map. @endif
|
||||
typedef _Rb_tree<key_type, value_type,
|
||||
_Select1st<value_type>, key_compare, _Alloc> _Rep_type;
|
||||
/// @if maint The actual tree structure. @endif
|
||||
_Rep_type _M_t;
|
||||
|
||||
private:
|
||||
/// @if maint This turns a red-black tree into a [multi]map. @endif
|
||||
typedef _Rb_tree<key_type, value_type,
|
||||
_Select1st<value_type>, key_compare, _Alloc> _Rep_type;
|
||||
/// @if maint The actual tree structure. @endif
|
||||
_Rep_type _M_t;
|
||||
|
||||
public:
|
||||
// many of these are specified differently in ISO, but the following are
|
||||
// "functionally equivalent"
|
||||
typedef typename _Rep_type::allocator_type allocator_type;
|
||||
typedef typename _Rep_type::reference reference;
|
||||
typedef typename _Rep_type::const_reference const_reference;
|
||||
typedef typename _Rep_type::iterator iterator;
|
||||
typedef typename _Rep_type::const_iterator const_iterator;
|
||||
typedef typename _Rep_type::size_type size_type;
|
||||
typedef typename _Rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::pointer pointer;
|
||||
typedef typename _Rep_type::const_pointer const_pointer;
|
||||
typedef typename _Rep_type::reverse_iterator reverse_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
public:
|
||||
// many of these are specified differently in ISO, but the following are
|
||||
// "functionally equivalent"
|
||||
typedef typename _Rep_type::allocator_type allocator_type;
|
||||
typedef typename _Rep_type::reference reference;
|
||||
typedef typename _Rep_type::const_reference const_reference;
|
||||
typedef typename _Rep_type::iterator iterator;
|
||||
typedef typename _Rep_type::const_iterator const_iterator;
|
||||
typedef typename _Rep_type::size_type size_type;
|
||||
typedef typename _Rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::pointer pointer;
|
||||
typedef typename _Rep_type::const_pointer const_pointer;
|
||||
typedef typename _Rep_type::reverse_iterator reverse_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
|
||||
// [23.3.2] construct/copy/destroy
|
||||
// (get_allocator() is also listed in this section)
|
||||
/**
|
||||
* @brief Default constructor creates no elements.
|
||||
*/
|
||||
multimap() : _M_t(_Compare(), allocator_type()) { }
|
||||
// [23.3.2] construct/copy/destroy
|
||||
// (get_allocator() is also listed in this section)
|
||||
/**
|
||||
* @brief Default constructor creates no elements.
|
||||
*/
|
||||
multimap()
|
||||
: _M_t(_Compare(), allocator_type()) { }
|
||||
|
||||
// for some reason this was made a separate function
|
||||
/**
|
||||
* @brief Default constructor creates no elements.
|
||||
*/
|
||||
explicit
|
||||
multimap(const _Compare& __comp, const allocator_type& __a = allocator_type())
|
||||
// for some reason this was made a separate function
|
||||
/**
|
||||
* @brief Default constructor creates no elements.
|
||||
*/
|
||||
explicit
|
||||
multimap(const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { }
|
||||
|
||||
/**
|
||||
* @brief %Multimap copy constructor.
|
||||
* @param x A %multimap of identical element and allocator types.
|
||||
*
|
||||
* The newly-created %multimap uses a copy of the allocation object used
|
||||
* by @a x.
|
||||
*/
|
||||
multimap(const multimap& __x)
|
||||
/**
|
||||
* @brief %Multimap copy constructor.
|
||||
* @param x A %multimap of identical element and allocator types.
|
||||
*
|
||||
* The newly-created %multimap uses a copy of the allocation object used
|
||||
* by @a x.
|
||||
*/
|
||||
multimap(const multimap& __x)
|
||||
: _M_t(__x._M_t) { }
|
||||
|
||||
/**
|
||||
* @brief Builds a %multimap from a range.
|
||||
* @param first An input iterator.
|
||||
* @param last An input iterator.
|
||||
*
|
||||
* Create a %multimap consisting of copies of the elements from
|
||||
* [first,last). This is linear in N if the range is already sorted,
|
||||
* and NlogN otherwise (where N is distance(first,last)).
|
||||
*/
|
||||
template <typename _InputIterator>
|
||||
multimap(_InputIterator __first, _InputIterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
/**
|
||||
* @brief Builds a %multimap from a range.
|
||||
* @param first An input iterator.
|
||||
* @param last An input iterator.
|
||||
*
|
||||
* Create a %multimap consisting of copies of the elements from
|
||||
* [first,last). This is linear in N if the range is already sorted,
|
||||
* and NlogN otherwise (where N is distance(first,last)).
|
||||
*/
|
||||
template <typename _InputIterator>
|
||||
multimap(_InputIterator __first, _InputIterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
|
||||
/**
|
||||
* @brief Builds a %multimap from a range.
|
||||
* @param first An input iterator.
|
||||
* @param last An input iterator.
|
||||
* @param comp A comparison functor.
|
||||
* @param a An allocator object.
|
||||
*
|
||||
* Create a %multimap consisting of copies of the elements from
|
||||
* [first,last). This is linear in N if the range is already sorted,
|
||||
* and NlogN otherwise (where N is distance(first,last)).
|
||||
*/
|
||||
template <typename _InputIterator>
|
||||
multimap(_InputIterator __first, _InputIterator __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
/**
|
||||
* @brief Builds a %multimap from a range.
|
||||
* @param first An input iterator.
|
||||
* @param last An input iterator.
|
||||
* @param comp A comparison functor.
|
||||
* @param a An allocator object.
|
||||
*
|
||||
* Create a %multimap consisting of copies of the elements from
|
||||
* [first,last). This is linear in N if the range is already sorted,
|
||||
* and NlogN otherwise (where N is distance(first,last)).
|
||||
*/
|
||||
template <typename _InputIterator>
|
||||
multimap(_InputIterator __first, _InputIterator __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a)
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
|
||||
// FIXME There is no dtor declared, but we should have something generated
|
||||
// by Doxygen. I don't know what tags to add to this paragraph to make
|
||||
// that happen:
|
||||
/**
|
||||
* The dtor only erases the elements, and note that if the elements
|
||||
* themselves are pointers, the pointed-to memory is not touched in any
|
||||
* way. Managing the pointer is the user's responsibilty.
|
||||
*/
|
||||
// FIXME There is no dtor declared, but we should have something generated
|
||||
// by Doxygen. I don't know what tags to add to this paragraph to make
|
||||
// that happen:
|
||||
/**
|
||||
* The dtor only erases the elements, and note that if the elements
|
||||
* themselves are pointers, the pointed-to memory is not touched in any
|
||||
* way. Managing the pointer is the user's responsibilty.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief %Multimap assignment operator.
|
||||
* @param x A %multimap of identical element and allocator types.
|
||||
*
|
||||
* All the elements of @a x are copied, but unlike the copy constructor,
|
||||
* the allocator object is not copied.
|
||||
*/
|
||||
multimap&
|
||||
operator=(const multimap& __x)
|
||||
{
|
||||
_M_t = __x._M_t;
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @brief %Multimap assignment operator.
|
||||
* @param x A %multimap of identical element and allocator types.
|
||||
*
|
||||
* All the elements of @a x are copied, but unlike the copy constructor,
|
||||
* the allocator object is not copied.
|
||||
*/
|
||||
multimap&
|
||||
operator=(const multimap& __x)
|
||||
{
|
||||
_M_t = __x._M_t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Get a copy of the memory allocation object.
|
||||
allocator_type
|
||||
get_allocator() const
|
||||
{ return _M_t.get_allocator(); }
|
||||
|
||||
// iterators
|
||||
/**
|
||||
* Returns a read/write iterator that points to the first pair in the
|
||||
* %multimap. Iteration is done in ascending order according to the
|
||||
* keys.
|
||||
*/
|
||||
iterator
|
||||
begin()
|
||||
{ return _M_t.begin(); }
|
||||
|
||||
/// Get a copy of the memory allocation object.
|
||||
allocator_type
|
||||
get_allocator() const { return _M_t.get_allocator(); }
|
||||
/**
|
||||
* Returns a read-only (constant) iterator that points to the first pair
|
||||
* in the %multimap. Iteration is done in ascending order according to
|
||||
* the keys.
|
||||
*/
|
||||
const_iterator
|
||||
begin() const
|
||||
{ return _M_t.begin(); }
|
||||
|
||||
/**
|
||||
* Returns a read/write iterator that points one past the last pair in
|
||||
* the %multimap. Iteration is done in ascending order according to the
|
||||
* keys.
|
||||
*/
|
||||
iterator
|
||||
end()
|
||||
{ return _M_t.end(); }
|
||||
|
||||
/**
|
||||
* Returns a read-only (constant) iterator that points one past the last
|
||||
* pair in the %multimap. Iteration is done in ascending order according
|
||||
* to the keys.
|
||||
*/
|
||||
const_iterator
|
||||
end() const
|
||||
{ return _M_t.end(); }
|
||||
|
||||
/**
|
||||
* Returns a read/write reverse iterator that points to the last pair in
|
||||
* the %multimap. Iteration is done in descending order according to the
|
||||
* keys.
|
||||
*/
|
||||
reverse_iterator
|
||||
rbegin()
|
||||
{ return _M_t.rbegin(); }
|
||||
|
||||
/**
|
||||
* Returns a read-only (constant) reverse iterator that points to the
|
||||
* last pair in the %multimap. Iteration is done in descending order
|
||||
* according to the keys.
|
||||
*/
|
||||
const_reverse_iterator
|
||||
rbegin() const
|
||||
{ return _M_t.rbegin(); }
|
||||
|
||||
/**
|
||||
* Returns a read/write reverse iterator that points to one before the
|
||||
* first pair in the %multimap. Iteration is done in descending order
|
||||
* according to the keys.
|
||||
*/
|
||||
reverse_iterator
|
||||
rend()
|
||||
{ return _M_t.rend(); }
|
||||
|
||||
/**
|
||||
* Returns a read-only (constant) reverse iterator that points to one
|
||||
* before the first pair in the %multimap. Iteration is done in
|
||||
* descending order according to the keys.
|
||||
*/
|
||||
const_reverse_iterator
|
||||
rend() const
|
||||
{ return _M_t.rend(); }
|
||||
|
||||
// capacity
|
||||
/** Returns true if the %multimap is empty. */
|
||||
bool
|
||||
empty() const
|
||||
{ return _M_t.empty(); }
|
||||
|
||||
/** Returns the size of the %multimap. */
|
||||
size_type
|
||||
size() const
|
||||
{ return _M_t.size(); }
|
||||
|
||||
/** Returns the maximum size of the %multimap. */
|
||||
size_type
|
||||
max_size() const
|
||||
{ return _M_t.max_size(); }
|
||||
|
||||
// modifiers
|
||||
/**
|
||||
* @brief Inserts a std::pair into the %multimap.
|
||||
* @param x Pair to be inserted (see std::make_pair for easy creation
|
||||
* of pairs).
|
||||
* @return An iterator that points to the inserted (key,value) pair.
|
||||
*
|
||||
* This function inserts a (key, value) pair into the %multimap.
|
||||
* Contrary to a std::map the %multimap does not rely on unique keys and
|
||||
* thus multiple pairs with the same key can be inserted.
|
||||
*
|
||||
* Insertion requires logarithmic time.
|
||||
*/
|
||||
iterator
|
||||
insert(const value_type& __x)
|
||||
{ return _M_t.insert_equal(__x); }
|
||||
|
||||
// iterators
|
||||
/**
|
||||
* Returns a read/write iterator that points to the first pair in the
|
||||
* %multimap. Iteration is done in ascending order according to the keys.
|
||||
*/
|
||||
iterator
|
||||
begin() { return _M_t.begin(); }
|
||||
/**
|
||||
* @brief Inserts a std::pair into the %multimap.
|
||||
* @param position An iterator that serves as a hint as to where the
|
||||
* pair should be inserted.
|
||||
* @param x Pair to be inserted (see std::make_pair for easy creation
|
||||
* of pairs).
|
||||
* @return An iterator that points to the inserted (key,value) pair.
|
||||
*
|
||||
* This function inserts a (key, value) pair into the %multimap.
|
||||
* Contrary to a std::map the %multimap does not rely on unique keys and
|
||||
* thus multiple pairs with the same key can be inserted.
|
||||
* Note that the first parameter is only a hint and can potentially
|
||||
* improve the performance of the insertion process. A bad hint would
|
||||
* cause no gains in efficiency.
|
||||
*
|
||||
* See http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html#4
|
||||
* for more on "hinting".
|
||||
*
|
||||
* Insertion requires logarithmic time (if the hint is not taken).
|
||||
*/
|
||||
iterator
|
||||
insert(iterator __position, const value_type& __x)
|
||||
{ return _M_t.insert_equal(__position, __x); }
|
||||
|
||||
/**
|
||||
* @brief A template function that attemps to insert a range of elements.
|
||||
* @param first Iterator pointing to the start of the range to be
|
||||
* inserted.
|
||||
* @param last Iterator pointing to the end of the range.
|
||||
*
|
||||
* Complexity similar to that of the range constructor.
|
||||
*/
|
||||
template <typename _InputIterator>
|
||||
void
|
||||
insert(_InputIterator __first, _InputIterator __last)
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
|
||||
/**
|
||||
* Returns a read-only (constant) iterator that points to the first pair
|
||||
* in the %multimap. Iteration is done in ascending order according to the
|
||||
* keys.
|
||||
*/
|
||||
const_iterator
|
||||
begin() const { return _M_t.begin(); }
|
||||
|
||||
/**
|
||||
* Returns a read/write iterator that points one past the last pair in the
|
||||
* %multimap. Iteration is done in ascending order according to the keys.
|
||||
*/
|
||||
iterator
|
||||
end() { return _M_t.end(); }
|
||||
|
||||
/**
|
||||
* Returns a read-only (constant) iterator that points one past the last
|
||||
* pair in the %multimap. Iteration is done in ascending order according
|
||||
* to the keys.
|
||||
*/
|
||||
const_iterator
|
||||
end() const { return _M_t.end(); }
|
||||
|
||||
/**
|
||||
* Returns a read/write reverse iterator that points to the last pair in
|
||||
* the %multimap. Iteration is done in descending order according to the
|
||||
* keys.
|
||||
*/
|
||||
reverse_iterator
|
||||
rbegin() { return _M_t.rbegin(); }
|
||||
|
||||
/**
|
||||
* Returns a read-only (constant) reverse iterator that points to the last
|
||||
* pair in the %multimap. Iteration is done in descending order according
|
||||
* to the keys.
|
||||
*/
|
||||
const_reverse_iterator
|
||||
rbegin() const { return _M_t.rbegin(); }
|
||||
|
||||
/**
|
||||
* Returns a read/write reverse iterator that points to one before the
|
||||
* first pair in the %multimap. Iteration is done in descending order
|
||||
* according to the keys.
|
||||
*/
|
||||
reverse_iterator
|
||||
rend() { return _M_t.rend(); }
|
||||
|
||||
/**
|
||||
* Returns a read-only (constant) reverse iterator that points to one
|
||||
* before the first pair in the %multimap. Iteration is done in descending
|
||||
* order according to the keys.
|
||||
*/
|
||||
const_reverse_iterator
|
||||
rend() const { return _M_t.rend(); }
|
||||
|
||||
// capacity
|
||||
/** Returns true if the %multimap is empty. */
|
||||
bool
|
||||
empty() const { return _M_t.empty(); }
|
||||
|
||||
/** Returns the size of the %multimap. */
|
||||
size_type
|
||||
size() const { return _M_t.size(); }
|
||||
|
||||
/** Returns the maximum size of the %multimap. */
|
||||
size_type
|
||||
max_size() const { return _M_t.max_size(); }
|
||||
|
||||
// modifiers
|
||||
/**
|
||||
* @brief Inserts a std::pair into the %multimap.
|
||||
* @param x Pair to be inserted (see std::make_pair for easy creation of
|
||||
* pairs).
|
||||
* @return An iterator that points to the inserted (key,value) pair.
|
||||
*
|
||||
* This function inserts a (key, value) pair into the %multimap. Contrary
|
||||
* to a std::map the %multimap does not rely on unique keys and thus
|
||||
* multiple pairs with the same key can be inserted.
|
||||
*
|
||||
* Insertion requires logarithmic time.
|
||||
*/
|
||||
iterator
|
||||
insert(const value_type& __x) { return _M_t.insert_equal(__x); }
|
||||
|
||||
/**
|
||||
* @brief Inserts a std::pair into the %multimap.
|
||||
* @param position An iterator that serves as a hint as to where the
|
||||
* pair should be inserted.
|
||||
* @param x Pair to be inserted (see std::make_pair for easy creation of
|
||||
* pairs).
|
||||
* @return An iterator that points to the inserted (key,value) pair.
|
||||
*
|
||||
* This function inserts a (key, value) pair into the %multimap. Contrary
|
||||
* to a std::map the %multimap does not rely on unique keys and thus
|
||||
* multiple pairs with the same key can be inserted.
|
||||
* Note that the first parameter is only a hint and can potentially
|
||||
* improve the performance of the insertion process. A bad hint would
|
||||
* cause no gains in efficiency.
|
||||
*
|
||||
* See http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html#4
|
||||
* for more on "hinting".
|
||||
*
|
||||
* Insertion requires logarithmic time (if the hint is not taken).
|
||||
*/
|
||||
iterator
|
||||
insert(iterator __position, const value_type& __x)
|
||||
{ return _M_t.insert_equal(__position, __x); }
|
||||
|
||||
/**
|
||||
* @brief A template function that attemps to insert a range of elements.
|
||||
* @param first Iterator pointing to the start of the range to be
|
||||
* inserted.
|
||||
* @param last Iterator pointing to the end of the range.
|
||||
*
|
||||
* Complexity similar to that of the range constructor.
|
||||
*/
|
||||
template <typename _InputIterator>
|
||||
/**
|
||||
* @brief Erases an element from a %multimap.
|
||||
* @param position An iterator pointing to the element to be erased.
|
||||
*
|
||||
* This function erases an element, pointed to by the given iterator,
|
||||
* from a %multimap. Note that this function only erases the element,
|
||||
* and that if the element is itself a pointer, the pointed-to memory is
|
||||
* not touched in any way. Managing the pointer is the user's
|
||||
* responsibilty.
|
||||
*/
|
||||
void
|
||||
insert(_InputIterator __first, _InputIterator __last)
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
erase(iterator __position)
|
||||
{ _M_t.erase(__position); }
|
||||
|
||||
/**
|
||||
* @brief Erases elements according to the provided key.
|
||||
* @param x Key of element to be erased.
|
||||
* @return The number of elements erased.
|
||||
*
|
||||
* This function erases all elements located by the given key from a
|
||||
* %multimap.
|
||||
* Note that this function only erases the element, and that if
|
||||
* the element is itself a pointer, the pointed-to memory is not touched
|
||||
* in any way. Managing the pointer is the user's responsibilty.
|
||||
*/
|
||||
size_type
|
||||
erase(const key_type& __x)
|
||||
{ return _M_t.erase(__x); }
|
||||
|
||||
/**
|
||||
* @brief Erases an element from a %multimap.
|
||||
* @param position An iterator pointing to the element to be erased.
|
||||
*
|
||||
* This function erases an element, pointed to by the given iterator, from
|
||||
* a %multimap. Note that this function only erases the element, and that
|
||||
* if the element is itself a pointer, the pointed-to memory is not
|
||||
* touched in any way. Managing the pointer is the user's responsibilty.
|
||||
*/
|
||||
void
|
||||
erase(iterator __position) { _M_t.erase(__position); }
|
||||
/**
|
||||
* @brief Erases a [first,last) range of elements from a %multimap.
|
||||
* @param first Iterator pointing to the start of the range to be
|
||||
* erased.
|
||||
* @param last Iterator pointing to the end of the range to be erased.
|
||||
*
|
||||
* This function erases a sequence of elements from a %multimap.
|
||||
* Note that this function only erases the elements, and that if
|
||||
* the elements themselves are pointers, the pointed-to memory is not
|
||||
* touched in any way. Managing the pointer is the user's responsibilty.
|
||||
*/
|
||||
void
|
||||
erase(iterator __first, iterator __last)
|
||||
{ _M_t.erase(__first, __last); }
|
||||
|
||||
/**
|
||||
* @brief Swaps data with another %multimap.
|
||||
* @param x A %multimap of the same element and allocator types.
|
||||
*
|
||||
* This exchanges the elements between two multimaps in constant time.
|
||||
* (It is only swapping a pointer, an integer, and an instance of
|
||||
* the @c Compare type (which itself is often stateless and empty), so it
|
||||
* should be quite fast.)
|
||||
* Note that the global std::swap() function is specialized such that
|
||||
* std::swap(m1,m2) will feed to this function.
|
||||
*/
|
||||
void
|
||||
swap(multimap& __x)
|
||||
{ _M_t.swap(__x._M_t); }
|
||||
|
||||
/**
|
||||
* Erases all elements in a %multimap. Note that this function only
|
||||
* erases the elements, and that if the elements themselves are pointers,
|
||||
* the pointed-to memory is not touched in any way. Managing the pointer
|
||||
* is the user's responsibilty.
|
||||
*/
|
||||
void
|
||||
clear()
|
||||
{ _M_t.clear(); }
|
||||
|
||||
// observers
|
||||
/**
|
||||
* Returns the key comparison object out of which the %multimap
|
||||
* was constructed.
|
||||
*/
|
||||
key_compare
|
||||
key_comp() const
|
||||
{ return _M_t.key_comp(); }
|
||||
|
||||
/**
|
||||
* Returns a value comparison object, built from the key comparison
|
||||
* object out of which the %multimap was constructed.
|
||||
*/
|
||||
value_compare
|
||||
value_comp() const
|
||||
{ return value_compare(_M_t.key_comp()); }
|
||||
|
||||
// multimap operations
|
||||
/**
|
||||
* @brief Tries to locate an element in a %multimap.
|
||||
* @param x Key of (key, value) pair to be located.
|
||||
* @return Iterator pointing to sought-after element,
|
||||
* or end() if not found.
|
||||
*
|
||||
* This function takes a key and tries to locate the element with which
|
||||
* the key matches. If successful the function returns an iterator
|
||||
* pointing to the sought after %pair. If unsuccessful it returns the
|
||||
* past-the-end ( @c end() ) iterator.
|
||||
*/
|
||||
iterator
|
||||
find(const key_type& __x)
|
||||
{ return _M_t.find(__x); }
|
||||
|
||||
/**
|
||||
* @brief Tries to locate an element in a %multimap.
|
||||
* @param x Key of (key, value) pair to be located.
|
||||
* @return Read-only (constant) iterator pointing to sought-after
|
||||
* element, or end() if not found.
|
||||
*
|
||||
* This function takes a key and tries to locate the element with which
|
||||
* the key matches. If successful the function returns a constant
|
||||
* iterator pointing to the sought after %pair. If unsuccessful it
|
||||
* returns the past-the-end ( @c end() ) iterator.
|
||||
*/
|
||||
const_iterator
|
||||
find(const key_type& __x) const
|
||||
{ return _M_t.find(__x); }
|
||||
|
||||
/**
|
||||
* @brief Finds the number of elements with given key.
|
||||
* @param x Key of (key, value) pairs to be located.
|
||||
* @return Number of elements with specified key.
|
||||
*/
|
||||
size_type
|
||||
count(const key_type& __x) const
|
||||
{ return _M_t.count(__x); }
|
||||
|
||||
/**
|
||||
* @brief Finds the beginning of a subsequence matching given key.
|
||||
* @param x Key of (key, value) pair to be located.
|
||||
* @return Iterator pointing to first element equal to or greater
|
||||
* than key, or end().
|
||||
*
|
||||
* This function returns the first element of a subsequence of elements
|
||||
* that matches the given key. If unsuccessful it returns an iterator
|
||||
* pointing to the first element that has a greater value than given key
|
||||
* or end() if no such element exists.
|
||||
*/
|
||||
iterator
|
||||
lower_bound(const key_type& __x)
|
||||
{ return _M_t.lower_bound(__x); }
|
||||
|
||||
/**
|
||||
* @brief Erases elements according to the provided key.
|
||||
* @param x Key of element to be erased.
|
||||
* @return The number of elements erased.
|
||||
*
|
||||
* This function erases all elements located by the given key from a
|
||||
* %multimap.
|
||||
* Note that this function only erases the element, and that if
|
||||
* the element is itself a pointer, the pointed-to memory is not touched
|
||||
* in any way. Managing the pointer is the user's responsibilty.
|
||||
*/
|
||||
size_type
|
||||
erase(const key_type& __x) { return _M_t.erase(__x); }
|
||||
/**
|
||||
* @brief Finds the beginning of a subsequence matching given key.
|
||||
* @param x Key of (key, value) pair to be located.
|
||||
* @return Read-only (constant) iterator pointing to first element
|
||||
* equal to or greater than key, or end().
|
||||
*
|
||||
* This function returns the first element of a subsequence of elements
|
||||
* that matches the given key. If unsuccessful the iterator will point
|
||||
* to the next greatest element or, if no such greater element exists, to
|
||||
* end().
|
||||
*/
|
||||
const_iterator
|
||||
lower_bound(const key_type& __x) const
|
||||
{ return _M_t.lower_bound(__x); }
|
||||
|
||||
/**
|
||||
* @brief Finds the end of a subsequence matching given key.
|
||||
* @param x Key of (key, value) pair to be located.
|
||||
* @return Iterator pointing to the first element
|
||||
* greater than key, or end().
|
||||
*/
|
||||
iterator
|
||||
upper_bound(const key_type& __x)
|
||||
{ return _M_t.upper_bound(__x); }
|
||||
|
||||
/**
|
||||
* @brief Finds the end of a subsequence matching given key.
|
||||
* @param x Key of (key, value) pair to be located.
|
||||
* @return Read-only (constant) iterator pointing to first iterator
|
||||
* greater than key, or end().
|
||||
*/
|
||||
const_iterator
|
||||
upper_bound(const key_type& __x) const
|
||||
{ return _M_t.upper_bound(__x); }
|
||||
|
||||
/**
|
||||
* @brief Erases a [first,last) range of elements from a %multimap.
|
||||
* @param first Iterator pointing to the start of the range to be erased.
|
||||
* @param last Iterator pointing to the end of the range to be erased.
|
||||
*
|
||||
* This function erases a sequence of elements from a %multimap.
|
||||
* Note that this function only erases the elements, and that if
|
||||
* the elements themselves are pointers, the pointed-to memory is not
|
||||
* touched in any way. Managing the pointer is the user's responsibilty.
|
||||
*/
|
||||
void
|
||||
erase(iterator __first, iterator __last) { _M_t.erase(__first, __last); }
|
||||
/**
|
||||
* @brief Finds a subsequence matching given key.
|
||||
* @param x Key of (key, value) pairs to be located.
|
||||
* @return Pair of iterators that possibly points to the subsequence
|
||||
* matching given key.
|
||||
*
|
||||
* This function is equivalent to
|
||||
* @code
|
||||
* std::make_pair(c.lower_bound(val),
|
||||
* c.upper_bound(val))
|
||||
* @endcode
|
||||
* (but is faster than making the calls separately).
|
||||
*/
|
||||
pair<iterator,iterator>
|
||||
equal_range(const key_type& __x)
|
||||
{ return _M_t.equal_range(__x); }
|
||||
|
||||
/**
|
||||
* @brief Swaps data with another %multimap.
|
||||
* @param x A %multimap of the same element and allocator types.
|
||||
*
|
||||
* This exchanges the elements between two multimaps in constant time.
|
||||
* (It is only swapping a pointer, an integer, and an instance of
|
||||
* the @c Compare type (which itself is often stateless and empty), so it
|
||||
* should be quite fast.)
|
||||
* Note that the global std::swap() function is specialized such that
|
||||
* std::swap(m1,m2) will feed to this function.
|
||||
*/
|
||||
void
|
||||
swap(multimap& __x) { _M_t.swap(__x._M_t); }
|
||||
/**
|
||||
* @brief Finds a subsequence matching given key.
|
||||
* @param x Key of (key, value) pairs to be located.
|
||||
* @return Pair of read-only (constant) iterators that possibly points
|
||||
* to the subsequence matching given key.
|
||||
*
|
||||
* This function is equivalent to
|
||||
* @code
|
||||
* std::make_pair(c.lower_bound(val),
|
||||
* c.upper_bound(val))
|
||||
* @endcode
|
||||
* (but is faster than making the calls separately).
|
||||
*/
|
||||
pair<const_iterator,const_iterator>
|
||||
equal_range(const key_type& __x) const
|
||||
{ return _M_t.equal_range(__x); }
|
||||
|
||||
/**
|
||||
* Erases all elements in a %multimap. Note that this function only erases
|
||||
* the elements, and that if the elements themselves are pointers, the
|
||||
* pointed-to memory is not touched in any way. Managing the pointer is
|
||||
* the user's responsibilty.
|
||||
*/
|
||||
void
|
||||
clear() { _M_t.clear(); }
|
||||
|
||||
// observers
|
||||
/**
|
||||
* Returns the key comparison object out of which the %multimap
|
||||
* was constructed.
|
||||
*/
|
||||
key_compare
|
||||
key_comp() const { return _M_t.key_comp(); }
|
||||
|
||||
/**
|
||||
* Returns a value comparison object, built from the key comparison
|
||||
* object out of which the %multimap was constructed.
|
||||
*/
|
||||
value_compare
|
||||
value_comp() const { return value_compare(_M_t.key_comp()); }
|
||||
|
||||
// multimap operations
|
||||
/**
|
||||
* @brief Tries to locate an element in a %multimap.
|
||||
* @param x Key of (key, value) pair to be located.
|
||||
* @return Iterator pointing to sought-after element,
|
||||
* or end() if not found.
|
||||
*
|
||||
* This function takes a key and tries to locate the element with which
|
||||
* the key matches. If successful the function returns an iterator
|
||||
* pointing to the sought after %pair. If unsuccessful it returns the
|
||||
* past-the-end ( @c end() ) iterator.
|
||||
*/
|
||||
iterator
|
||||
find(const key_type& __x) { return _M_t.find(__x); }
|
||||
|
||||
/**
|
||||
* @brief Tries to locate an element in a %multimap.
|
||||
* @param x Key of (key, value) pair to be located.
|
||||
* @return Read-only (constant) iterator pointing to sought-after
|
||||
* element, or end() if not found.
|
||||
*
|
||||
* This function takes a key and tries to locate the element with which
|
||||
* the key matches. If successful the function returns a constant iterator
|
||||
* pointing to the sought after %pair. If unsuccessful it returns the
|
||||
* past-the-end ( @c end() ) iterator.
|
||||
*/
|
||||
const_iterator
|
||||
find(const key_type& __x) const { return _M_t.find(__x); }
|
||||
|
||||
/**
|
||||
* @brief Finds the number of elements with given key.
|
||||
* @param x Key of (key, value) pairs to be located.
|
||||
* @return Number of elements with specified key.
|
||||
*/
|
||||
size_type
|
||||
count(const key_type& __x) const { return _M_t.count(__x); }
|
||||
|
||||
/**
|
||||
* @brief Finds the beginning of a subsequence matching given key.
|
||||
* @param x Key of (key, value) pair to be located.
|
||||
* @return Iterator pointing to first element equal to or greater
|
||||
* than key, or end().
|
||||
*
|
||||
* This function returns the first element of a subsequence of elements
|
||||
* that matches the given key. If unsuccessful it returns an iterator
|
||||
* pointing to the first element that has a greater value than given key
|
||||
* or end() if no such element exists.
|
||||
*/
|
||||
iterator
|
||||
lower_bound(const key_type& __x) { return _M_t.lower_bound(__x); }
|
||||
|
||||
/**
|
||||
* @brief Finds the beginning of a subsequence matching given key.
|
||||
* @param x Key of (key, value) pair to be located.
|
||||
* @return Read-only (constant) iterator pointing to first element
|
||||
* equal to or greater than key, or end().
|
||||
*
|
||||
* This function returns the first element of a subsequence of elements
|
||||
* that matches the given key. If unsuccessful the iterator will point
|
||||
* to the next greatest element or, if no such greater element exists, to
|
||||
* end().
|
||||
*/
|
||||
const_iterator
|
||||
lower_bound(const key_type& __x) const { return _M_t.lower_bound(__x); }
|
||||
|
||||
/**
|
||||
* @brief Finds the end of a subsequence matching given key.
|
||||
* @param x Key of (key, value) pair to be located.
|
||||
* @return Iterator pointing to the first element
|
||||
* greater than key, or end().
|
||||
*/
|
||||
iterator
|
||||
upper_bound(const key_type& __x) { return _M_t.upper_bound(__x); }
|
||||
|
||||
/**
|
||||
* @brief Finds the end of a subsequence matching given key.
|
||||
* @param x Key of (key, value) pair to be located.
|
||||
* @return Read-only (constant) iterator pointing to first iterator
|
||||
* greater than key, or end().
|
||||
*/
|
||||
const_iterator
|
||||
upper_bound(const key_type& __x) const { return _M_t.upper_bound(__x); }
|
||||
|
||||
/**
|
||||
* @brief Finds a subsequence matching given key.
|
||||
* @param x Key of (key, value) pairs to be located.
|
||||
* @return Pair of iterators that possibly points to the subsequence
|
||||
* matching given key.
|
||||
*
|
||||
* This function is equivalent to
|
||||
* @code
|
||||
* std::make_pair(c.lower_bound(val),
|
||||
* c.upper_bound(val))
|
||||
* @endcode
|
||||
* (but is faster than making the calls separately).
|
||||
*/
|
||||
pair<iterator,iterator>
|
||||
equal_range(const key_type& __x) { return _M_t.equal_range(__x); }
|
||||
|
||||
/**
|
||||
* @brief Finds a subsequence matching given key.
|
||||
* @param x Key of (key, value) pairs to be located.
|
||||
* @return Pair of read-only (constant) iterators that possibly points to
|
||||
* the subsequence matching given key.
|
||||
*
|
||||
* This function is equivalent to
|
||||
* @code
|
||||
* std::make_pair(c.lower_bound(val),
|
||||
* c.upper_bound(val))
|
||||
* @endcode
|
||||
* (but is faster than making the calls separately).
|
||||
*/
|
||||
pair<const_iterator,const_iterator>
|
||||
equal_range(const key_type& __x) const { return _M_t.equal_range(__x); }
|
||||
|
||||
template <typename _K1, typename _T1, typename _C1, typename _A1>
|
||||
friend bool operator== (const multimap<_K1,_T1,_C1,_A1>&,
|
||||
const multimap<_K1,_T1,_C1,_A1>&);
|
||||
template <typename _K1, typename _T1, typename _C1, typename _A1>
|
||||
friend bool operator< (const multimap<_K1,_T1,_C1,_A1>&,
|
||||
const multimap<_K1,_T1,_C1,_A1>&);
|
||||
template <typename _K1, typename _T1, typename _C1, typename _A1>
|
||||
friend bool
|
||||
operator== (const multimap<_K1,_T1,_C1,_A1>&,
|
||||
const multimap<_K1,_T1,_C1,_A1>&);
|
||||
|
||||
template <typename _K1, typename _T1, typename _C1, typename _A1>
|
||||
friend bool
|
||||
operator< (const multimap<_K1,_T1,_C1,_A1>&,
|
||||
const multimap<_K1,_T1,_C1,_A1>&);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Multimap equality comparison.
|
||||
* @param x A %multimap.
|
||||
@ -577,9 +618,7 @@ namespace __gnu_norm
|
||||
inline bool
|
||||
operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
|
||||
const multimap<_Key,_Tp,_Compare,_Alloc>& __y)
|
||||
{
|
||||
return __x._M_t == __y._M_t;
|
||||
}
|
||||
{ return __x._M_t == __y._M_t; }
|
||||
|
||||
/**
|
||||
* @brief Multimap ordering relation.
|
||||
|
@ -66,19 +66,18 @@
|
||||
namespace __gnu_norm
|
||||
{
|
||||
|
||||
// Forward declaration of operators < and ==, needed for friend declaration.
|
||||
// Forward declaration of operators < and ==, needed for friend declaration.
|
||||
template <class _Key, class _Compare = less<_Key>,
|
||||
class _Alloc = allocator<_Key> >
|
||||
class multiset;
|
||||
|
||||
template <class _Key, class _Compare = less<_Key>,
|
||||
class _Alloc = allocator<_Key> >
|
||||
class multiset;
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
inline bool operator==(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
const multiset<_Key,_Compare,_Alloc>& __y);
|
||||
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
inline bool operator==(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
const multiset<_Key,_Compare,_Alloc>& __y);
|
||||
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
const multiset<_Key,_Compare,_Alloc>& __y);
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
const multiset<_Key,_Compare,_Alloc>& __y);
|
||||
|
||||
/**
|
||||
* @brief A standard container made up of elements, which can be retrieved
|
||||
@ -101,362 +100,410 @@ inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
* @endif
|
||||
*/
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
class multiset
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_class_requires(_Key, _SGIAssignableConcept)
|
||||
__glibcxx_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept)
|
||||
class multiset
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_class_requires(_Key, _SGIAssignableConcept)
|
||||
__glibcxx_class_requires4(_Compare, bool, _Key, _Key,
|
||||
_BinaryFunctionConcept)
|
||||
|
||||
public:
|
||||
// typedefs:
|
||||
typedef _Key key_type;
|
||||
typedef _Key value_type;
|
||||
typedef _Compare key_compare;
|
||||
typedef _Compare value_compare;
|
||||
|
||||
private:
|
||||
/// @if maint This turns a red-black tree into a [multi]set. @endif
|
||||
typedef _Rb_tree<key_type, value_type,
|
||||
_Identity<value_type>, key_compare, _Alloc> _Rep_type;
|
||||
/// @if maint The actual tree structure. @endif
|
||||
_Rep_type _M_t;
|
||||
|
||||
public:
|
||||
|
||||
// typedefs:
|
||||
|
||||
typedef _Key key_type;
|
||||
typedef _Key value_type;
|
||||
typedef _Compare key_compare;
|
||||
typedef _Compare value_compare;
|
||||
|
||||
private:
|
||||
/// @if maint This turns a red-black tree into a [multi]set. @endif
|
||||
typedef _Rb_tree<key_type, value_type,
|
||||
_Identity<value_type>, key_compare, _Alloc> _Rep_type;
|
||||
/// @if maint The actual tree structure. @endif
|
||||
_Rep_type _M_t;
|
||||
|
||||
public:
|
||||
typedef typename _Alloc::pointer pointer;
|
||||
typedef typename _Alloc::const_pointer const_pointer;
|
||||
typedef typename _Alloc::reference reference;
|
||||
typedef typename _Alloc::const_reference const_reference;
|
||||
typedef typename _Rep_type::const_iterator iterator;
|
||||
typedef typename _Rep_type::const_iterator const_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename _Rep_type::size_type size_type;
|
||||
typedef typename _Rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::allocator_type allocator_type;
|
||||
public:
|
||||
typedef typename _Alloc::pointer pointer;
|
||||
typedef typename _Alloc::const_pointer const_pointer;
|
||||
typedef typename _Alloc::reference reference;
|
||||
typedef typename _Alloc::const_reference const_reference;
|
||||
typedef typename _Rep_type::const_iterator iterator;
|
||||
typedef typename _Rep_type::const_iterator const_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename _Rep_type::size_type size_type;
|
||||
typedef typename _Rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::allocator_type allocator_type;
|
||||
|
||||
// allocation/deallocation
|
||||
|
||||
|
||||
/**
|
||||
* @brief Default constructor creates no elements.
|
||||
*/
|
||||
multiset() : _M_t(_Compare(), allocator_type()) {}
|
||||
explicit multiset(const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) {}
|
||||
|
||||
/**
|
||||
* @brief Builds a %multiset from a range.
|
||||
* @param first An input iterator.
|
||||
* @param last An input iterator.
|
||||
*
|
||||
* Create a %multiset consisting of copies of the elements from
|
||||
* [first,last). This is linear in N if the range is already sorted,
|
||||
* and NlogN otherwise (where N is distance(first,last)).
|
||||
*/
|
||||
template <class _InputIterator>
|
||||
multiset(_InputIterator __first, _InputIterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
|
||||
/**
|
||||
* @brief Builds a %multiset from a range.
|
||||
* @param first An input iterator.
|
||||
* @param last An input iterator.
|
||||
* @param comp A comparison functor.
|
||||
* @param a An allocator object.
|
||||
*
|
||||
* Create a %multiset consisting of copies of the elements from
|
||||
* [first,last). This is linear in N if the range is already sorted,
|
||||
* and NlogN otherwise (where N is distance(first,last)).
|
||||
*/
|
||||
template <class _InputIterator>
|
||||
multiset(_InputIterator __first, _InputIterator __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
||||
|
||||
/**
|
||||
* @brief %Multiset copy constructor.
|
||||
* @param x A %multiset of identical element and allocator types.
|
||||
*
|
||||
* The newly-created %multiset uses a copy of the allocation object used
|
||||
* by @a x.
|
||||
*/
|
||||
multiset(const multiset<_Key,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {}
|
||||
|
||||
/**
|
||||
* @brief %Multiset assignment operator.
|
||||
* @param x A %multiset of identical element and allocator types.
|
||||
*
|
||||
* All the elements of @a x are copied, but unlike the copy constructor,
|
||||
* the allocator object is not copied.
|
||||
*/
|
||||
multiset<_Key,_Compare,_Alloc>&
|
||||
operator=(const multiset<_Key,_Compare,_Alloc>& __x) {
|
||||
_M_t = __x._M_t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// accessors:
|
||||
|
||||
/// Returns the comparison object.
|
||||
key_compare key_comp() const { return _M_t.key_comp(); }
|
||||
/// Returns the comparison object.
|
||||
value_compare value_comp() const { return _M_t.key_comp(); }
|
||||
/// Returns the memory allocation object.
|
||||
allocator_type get_allocator() const { return _M_t.get_allocator(); }
|
||||
|
||||
/**
|
||||
* Returns a read/write iterator that points to the first element in the
|
||||
* %multiset. Iteration is done in ascending order according to the
|
||||
* keys.
|
||||
*/
|
||||
iterator begin() const { return _M_t.begin(); }
|
||||
multiset()
|
||||
: _M_t(_Compare(), allocator_type()) { }
|
||||
|
||||
/**
|
||||
* Returns a read/write iterator that points one past the last element in
|
||||
* the %multiset. Iteration is done in ascending order according to the
|
||||
* keys.
|
||||
*/
|
||||
iterator end() const { return _M_t.end(); }
|
||||
explicit multiset(const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { }
|
||||
|
||||
/**
|
||||
* Returns a read/write reverse iterator that points to the last element
|
||||
* in the %multiset. Iteration is done in descending order according to
|
||||
* the keys.
|
||||
*/
|
||||
reverse_iterator rbegin() const { return _M_t.rbegin(); }
|
||||
|
||||
/**
|
||||
* Returns a read/write reverse iterator that points to the last element
|
||||
* in the %multiset. Iteration is done in descending order according to
|
||||
* the keys.
|
||||
*/
|
||||
reverse_iterator rend() const { return _M_t.rend(); }
|
||||
/**
|
||||
* @brief Builds a %multiset from a range.
|
||||
* @param first An input iterator.
|
||||
* @param last An input iterator.
|
||||
*
|
||||
* Create a %multiset consisting of copies of the elements from
|
||||
* [first,last). This is linear in N if the range is already sorted,
|
||||
* and NlogN otherwise (where N is distance(first,last)).
|
||||
*/
|
||||
template <class _InputIterator>
|
||||
multiset(_InputIterator __first, _InputIterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
|
||||
/// Returns true if the %set is empty.
|
||||
bool empty() const { return _M_t.empty(); }
|
||||
/**
|
||||
* @brief Builds a %multiset from a range.
|
||||
* @param first An input iterator.
|
||||
* @param last An input iterator.
|
||||
* @param comp A comparison functor.
|
||||
* @param a An allocator object.
|
||||
*
|
||||
* Create a %multiset consisting of copies of the elements from
|
||||
* [first,last). This is linear in N if the range is already sorted,
|
||||
* and NlogN otherwise (where N is distance(first,last)).
|
||||
*/
|
||||
template <class _InputIterator>
|
||||
multiset(_InputIterator __first, _InputIterator __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a)
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
|
||||
/// Returns the size of the %set.
|
||||
size_type size() const { return _M_t.size(); }
|
||||
/**
|
||||
* @brief %Multiset copy constructor.
|
||||
* @param x A %multiset of identical element and allocator types.
|
||||
*
|
||||
* The newly-created %multiset uses a copy of the allocation object used
|
||||
* by @a x.
|
||||
*/
|
||||
multiset(const multiset<_Key,_Compare,_Alloc>& __x)
|
||||
: _M_t(__x._M_t) { }
|
||||
|
||||
/// Returns the maximum size of the %set.
|
||||
size_type max_size() const { return _M_t.max_size(); }
|
||||
/**
|
||||
* @brief %Multiset assignment operator.
|
||||
* @param x A %multiset of identical element and allocator types.
|
||||
*
|
||||
* All the elements of @a x are copied, but unlike the copy constructor,
|
||||
* the allocator object is not copied.
|
||||
*/
|
||||
multiset<_Key,_Compare,_Alloc>&
|
||||
operator=(const multiset<_Key,_Compare,_Alloc>& __x)
|
||||
{
|
||||
_M_t = __x._M_t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// accessors:
|
||||
|
||||
/// Returns the comparison object.
|
||||
key_compare
|
||||
key_comp() const
|
||||
{ return _M_t.key_comp(); }
|
||||
/// Returns the comparison object.
|
||||
value_compare
|
||||
value_comp() const
|
||||
{ return _M_t.key_comp(); }
|
||||
/// Returns the memory allocation object.
|
||||
allocator_type
|
||||
get_allocator() const
|
||||
{ return _M_t.get_allocator(); }
|
||||
|
||||
/**
|
||||
* Returns a read/write iterator that points to the first element in the
|
||||
* %multiset. Iteration is done in ascending order according to the
|
||||
* keys.
|
||||
*/
|
||||
iterator
|
||||
begin() const
|
||||
{ return _M_t.begin(); }
|
||||
|
||||
/**
|
||||
* @brief Swaps data with another %multiset.
|
||||
* @param x A %multiset of the same element and allocator types.
|
||||
*
|
||||
* This exchanges the elements between two multisets in constant time.
|
||||
* (It is only swapping a pointer, an integer, and an instance of the @c
|
||||
* Compare type (which itself is often stateless and empty), so it should
|
||||
* be quite fast.)
|
||||
* Note that the global std::swap() function is specialized such that
|
||||
* std::swap(s1,s2) will feed to this function.
|
||||
*/
|
||||
void swap(multiset<_Key,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }
|
||||
/**
|
||||
* Returns a read/write iterator that points one past the last element in
|
||||
* the %multiset. Iteration is done in ascending order according to the
|
||||
* keys.
|
||||
*/
|
||||
iterator
|
||||
end() const
|
||||
{ return _M_t.end(); }
|
||||
|
||||
/**
|
||||
* Returns a read/write reverse iterator that points to the last element
|
||||
* in the %multiset. Iteration is done in descending order according to
|
||||
* the keys.
|
||||
*/
|
||||
reverse_iterator
|
||||
rbegin() const
|
||||
{ return _M_t.rbegin(); }
|
||||
|
||||
/**
|
||||
* Returns a read/write reverse iterator that points to the last element
|
||||
* in the %multiset. Iteration is done in descending order according to
|
||||
* the keys.
|
||||
*/
|
||||
reverse_iterator
|
||||
rend() const
|
||||
{ return _M_t.rend(); }
|
||||
|
||||
/// Returns true if the %set is empty.
|
||||
bool
|
||||
empty() const
|
||||
{ return _M_t.empty(); }
|
||||
|
||||
/// Returns the size of the %set.
|
||||
size_type
|
||||
size() const
|
||||
{ return _M_t.size(); }
|
||||
|
||||
/// Returns the maximum size of the %set.
|
||||
size_type
|
||||
max_size() const
|
||||
{ return _M_t.max_size(); }
|
||||
|
||||
/**
|
||||
* @brief Swaps data with another %multiset.
|
||||
* @param x A %multiset of the same element and allocator types.
|
||||
*
|
||||
* This exchanges the elements between two multisets in constant time.
|
||||
* (It is only swapping a pointer, an integer, and an instance of the @c
|
||||
* Compare type (which itself is often stateless and empty), so it should
|
||||
* be quite fast.)
|
||||
* Note that the global std::swap() function is specialized such that
|
||||
* std::swap(s1,s2) will feed to this function.
|
||||
*/
|
||||
void
|
||||
swap(multiset<_Key,_Compare,_Alloc>& __x)
|
||||
{ _M_t.swap(__x._M_t); }
|
||||
|
||||
// insert/erase
|
||||
/**
|
||||
* @brief Inserts an element into the %multiset.
|
||||
* @param x Element to be inserted.
|
||||
* @return An iterator that points to the inserted element.
|
||||
*
|
||||
* This function inserts an element into the %multiset. Contrary
|
||||
* to a std::set the %multiset does not rely on unique keys and thus
|
||||
* multiple copies of the same element can be inserted.
|
||||
*
|
||||
* Insertion requires logarithmic time.
|
||||
*/
|
||||
iterator
|
||||
insert(const value_type& __x)
|
||||
{ return _M_t.insert_equal(__x); }
|
||||
|
||||
/**
|
||||
* @brief Inserts an element into the %multiset.
|
||||
* @param position An iterator that serves as a hint as to where the
|
||||
* element should be inserted.
|
||||
* @param x Element to be inserted.
|
||||
* @return An iterator that points to the inserted element.
|
||||
*
|
||||
* This function inserts an element into the %multiset. Contrary
|
||||
* to a std::set the %multiset does not rely on unique keys and thus
|
||||
* multiple copies of the same element can be inserted.
|
||||
*
|
||||
* Note that the first parameter is only a hint and can potentially
|
||||
* improve the performance of the insertion process. A bad hint would
|
||||
* cause no gains in efficiency.
|
||||
*
|
||||
* See http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html#4
|
||||
* for more on "hinting".
|
||||
*
|
||||
* Insertion requires logarithmic time (if the hint is not taken).
|
||||
*/
|
||||
iterator
|
||||
insert(iterator __position, const value_type& __x)
|
||||
{
|
||||
typedef typename _Rep_type::iterator _Rep_iterator;
|
||||
return _M_t.insert_equal((_Rep_iterator&)__position, __x);
|
||||
}
|
||||
|
||||
// insert/erase
|
||||
/**
|
||||
* @brief Inserts an element into the %multiset.
|
||||
* @param x Element to be inserted.
|
||||
* @return An iterator that points to the inserted element.
|
||||
*
|
||||
* This function inserts an element into the %multiset. Contrary
|
||||
* to a std::set the %multiset does not rely on unique keys and thus
|
||||
* multiple copies of the same element can be inserted.
|
||||
*
|
||||
* Insertion requires logarithmic time.
|
||||
*/
|
||||
iterator insert(const value_type& __x) {
|
||||
return _M_t.insert_equal(__x);
|
||||
}
|
||||
/**
|
||||
* @brief A template function that attemps to insert a range of elements.
|
||||
* @param first Iterator pointing to the start of the range to be
|
||||
* inserted.
|
||||
* @param last Iterator pointing to the end of the range.
|
||||
*
|
||||
* Complexity similar to that of the range constructor.
|
||||
*/
|
||||
template <class _InputIterator>
|
||||
void
|
||||
insert(_InputIterator __first, _InputIterator __last)
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
|
||||
/**
|
||||
* @brief Inserts an element into the %multiset.
|
||||
* @param position An iterator that serves as a hint as to where the
|
||||
* element should be inserted.
|
||||
* @param x Element to be inserted.
|
||||
* @return An iterator that points to the inserted element.
|
||||
*
|
||||
* This function inserts an element into the %multiset. Contrary
|
||||
* to a std::set the %multiset does not rely on unique keys and thus
|
||||
* multiple copies of the same element can be inserted.
|
||||
*
|
||||
* Note that the first parameter is only a hint and can potentially
|
||||
* improve the performance of the insertion process. A bad hint would
|
||||
* cause no gains in efficiency.
|
||||
*
|
||||
* See http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html#4
|
||||
* for more on "hinting".
|
||||
*
|
||||
* Insertion requires logarithmic time (if the hint is not taken).
|
||||
*/
|
||||
iterator insert(iterator __position, const value_type& __x) {
|
||||
typedef typename _Rep_type::iterator _Rep_iterator;
|
||||
return _M_t.insert_equal((_Rep_iterator&)__position, __x);
|
||||
}
|
||||
/**
|
||||
* @brief Erases an element from a %multiset.
|
||||
* @param position An iterator pointing to the element to be erased.
|
||||
*
|
||||
* This function erases an element, pointed to by the given iterator,
|
||||
* from a %multiset. Note that this function only erases the element,
|
||||
* and that if the element is itself a pointer, the pointed-to memory is
|
||||
* not touched in any way. Managing the pointer is the user's
|
||||
* responsibilty.
|
||||
*/
|
||||
void
|
||||
erase(iterator __position)
|
||||
{
|
||||
typedef typename _Rep_type::iterator _Rep_iterator;
|
||||
_M_t.erase((_Rep_iterator&)__position);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erases elements according to the provided key.
|
||||
* @param x Key of element to be erased.
|
||||
* @return The number of elements erased.
|
||||
*
|
||||
* This function erases all elements located by the given key from a
|
||||
* %multiset.
|
||||
* Note that this function only erases the element, and that if
|
||||
* the element is itself a pointer, the pointed-to memory is not touched
|
||||
* in any way. Managing the pointer is the user's responsibilty.
|
||||
*/
|
||||
size_type
|
||||
erase(const key_type& __x)
|
||||
{ return _M_t.erase(__x); }
|
||||
|
||||
/**
|
||||
* @brief Erases a [first,last) range of elements from a %multiset.
|
||||
* @param first Iterator pointing to the start of the range to be
|
||||
* erased.
|
||||
* @param last Iterator pointing to the end of the range to be erased.
|
||||
*
|
||||
* This function erases a sequence of elements from a %multiset.
|
||||
* Note that this function only erases the elements, and that if
|
||||
* the elements themselves are pointers, the pointed-to memory is not
|
||||
* touched in any way. Managing the pointer is the user's responsibilty.
|
||||
*/
|
||||
void
|
||||
erase(iterator __first, iterator __last)
|
||||
{
|
||||
typedef typename _Rep_type::iterator _Rep_iterator;
|
||||
_M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erases all elements in a %multiset. Note that this function only
|
||||
* erases the elements, and that if the elements themselves are pointers,
|
||||
* the pointed-to memory is not touched in any way. Managing the pointer
|
||||
* is the user's responsibilty.
|
||||
*/
|
||||
void
|
||||
clear()
|
||||
{ _M_t.clear(); }
|
||||
|
||||
// multiset operations:
|
||||
|
||||
/**
|
||||
* @brief Finds the number of elements with given key.
|
||||
* @param x Key of elements to be located.
|
||||
* @return Number of elements with specified key.
|
||||
*/
|
||||
size_type
|
||||
count(const key_type& __x) const
|
||||
{ return _M_t.count(__x); }
|
||||
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 214. set::find() missing const overload
|
||||
//@{
|
||||
/**
|
||||
* @brief Tries to locate an element in a %set.
|
||||
* @param x Element to be located.
|
||||
* @return Iterator pointing to sought-after element, or end() if not
|
||||
* found.
|
||||
*
|
||||
* This function takes a key and tries to locate the element with which
|
||||
* the key matches. If successful the function returns an iterator
|
||||
* pointing to the sought after element. If unsuccessful it returns the
|
||||
* past-the-end ( @c end() ) iterator.
|
||||
*/
|
||||
iterator
|
||||
find(const key_type& __x)
|
||||
{ return _M_t.find(__x); }
|
||||
|
||||
const_iterator
|
||||
find(const key_type& __x) const
|
||||
{ return _M_t.find(__x); }
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* @brief Finds the beginning of a subsequence matching given key.
|
||||
* @param x Key to be located.
|
||||
* @return Iterator pointing to first element equal to or greater
|
||||
* than key, or end().
|
||||
*
|
||||
* This function returns the first element of a subsequence of elements
|
||||
* that matches the given key. If unsuccessful it returns an iterator
|
||||
* pointing to the first element that has a greater value than given key
|
||||
* or end() if no such element exists.
|
||||
*/
|
||||
iterator
|
||||
lower_bound(const key_type& __x)
|
||||
{ return _M_t.lower_bound(__x); }
|
||||
|
||||
const_iterator
|
||||
lower_bound(const key_type& __x) const
|
||||
{ return _M_t.lower_bound(__x); }
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* @brief Finds the end of a subsequence matching given key.
|
||||
* @param x Key to be located.
|
||||
* @return Iterator pointing to the first element
|
||||
* greater than key, or end().
|
||||
*/
|
||||
iterator
|
||||
upper_bound(const key_type& __x)
|
||||
{ return _M_t.upper_bound(__x); }
|
||||
|
||||
const_iterator
|
||||
upper_bound(const key_type& __x) const
|
||||
{ return _M_t.upper_bound(__x); }
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* @brief Finds a subsequence matching given key.
|
||||
* @param x Key to be located.
|
||||
* @return Pair of iterators that possibly points to the subsequence
|
||||
* matching given key.
|
||||
*
|
||||
* This function is equivalent to
|
||||
* @code
|
||||
* std::make_pair(c.lower_bound(val),
|
||||
* c.upper_bound(val))
|
||||
* @endcode
|
||||
* (but is faster than making the calls separately).
|
||||
*
|
||||
* This function probably only makes sense for multisets.
|
||||
*/
|
||||
pair<iterator,iterator>
|
||||
equal_range(const key_type& __x)
|
||||
{ return _M_t.equal_range(__x); }
|
||||
|
||||
pair<const_iterator,const_iterator>
|
||||
equal_range(const key_type& __x) const
|
||||
{ return _M_t.equal_range(__x); }
|
||||
|
||||
template <class _K1, class _C1, class _A1>
|
||||
friend bool
|
||||
operator== (const multiset<_K1,_C1,_A1>&,
|
||||
const multiset<_K1,_C1,_A1>&);
|
||||
|
||||
/**
|
||||
* @brief A template function that attemps to insert a range of elements.
|
||||
* @param first Iterator pointing to the start of the range to be
|
||||
* inserted.
|
||||
* @param last Iterator pointing to the end of the range.
|
||||
*
|
||||
* Complexity similar to that of the range constructor.
|
||||
*/
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __first, _InputIterator __last) {
|
||||
_M_t.insert_equal(__first, __last);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erases an element from a %multiset.
|
||||
* @param position An iterator pointing to the element to be erased.
|
||||
*
|
||||
* This function erases an element, pointed to by the given iterator,
|
||||
* from a %multiset. Note that this function only erases the element,
|
||||
* and that if the element is itself a pointer, the pointed-to memory is
|
||||
* not touched in any way. Managing the pointer is the user's
|
||||
* responsibilty.
|
||||
*/
|
||||
void erase(iterator __position) {
|
||||
typedef typename _Rep_type::iterator _Rep_iterator;
|
||||
_M_t.erase((_Rep_iterator&)__position);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erases elements according to the provided key.
|
||||
* @param x Key of element to be erased.
|
||||
* @return The number of elements erased.
|
||||
*
|
||||
* This function erases all elements located by the given key from a
|
||||
* %multiset.
|
||||
* Note that this function only erases the element, and that if
|
||||
* the element is itself a pointer, the pointed-to memory is not touched
|
||||
* in any way. Managing the pointer is the user's responsibilty.
|
||||
*/
|
||||
size_type erase(const key_type& __x) {
|
||||
return _M_t.erase(__x);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erases a [first,last) range of elements from a %multiset.
|
||||
* @param first Iterator pointing to the start of the range to be erased.
|
||||
* @param last Iterator pointing to the end of the range to be erased.
|
||||
*
|
||||
* This function erases a sequence of elements from a %multiset.
|
||||
* Note that this function only erases the elements, and that if
|
||||
* the elements themselves are pointers, the pointed-to memory is not
|
||||
* touched in any way. Managing the pointer is the user's responsibilty.
|
||||
*/
|
||||
void erase(iterator __first, iterator __last) {
|
||||
typedef typename _Rep_type::iterator _Rep_iterator;
|
||||
_M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erases all elements in a %multiset. Note that this function only
|
||||
* erases the elements, and that if the elements themselves are pointers,
|
||||
* the pointed-to memory is not touched in any way. Managing the pointer
|
||||
* is the user's responsibilty.
|
||||
*/
|
||||
void clear() { _M_t.clear(); }
|
||||
|
||||
// multiset operations:
|
||||
|
||||
/**
|
||||
* @brief Finds the number of elements with given key.
|
||||
* @param x Key of elements to be located.
|
||||
* @return Number of elements with specified key.
|
||||
*/
|
||||
size_type count(const key_type& __x) const { return _M_t.count(__x); }
|
||||
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 214. set::find() missing const overload
|
||||
//@{
|
||||
/**
|
||||
* @brief Tries to locate an element in a %set.
|
||||
* @param x Element to be located.
|
||||
* @return Iterator pointing to sought-after element, or end() if not
|
||||
* found.
|
||||
*
|
||||
* This function takes a key and tries to locate the element with which
|
||||
* the key matches. If successful the function returns an iterator
|
||||
* pointing to the sought after element. If unsuccessful it returns the
|
||||
* past-the-end ( @c end() ) iterator.
|
||||
*/
|
||||
iterator find(const key_type& __x) { return _M_t.find(__x); }
|
||||
const_iterator find(const key_type& __x) const { return _M_t.find(__x); }
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* @brief Finds the beginning of a subsequence matching given key.
|
||||
* @param x Key to be located.
|
||||
* @return Iterator pointing to first element equal to or greater
|
||||
* than key, or end().
|
||||
*
|
||||
* This function returns the first element of a subsequence of elements
|
||||
* that matches the given key. If unsuccessful it returns an iterator
|
||||
* pointing to the first element that has a greater value than given key
|
||||
* or end() if no such element exists.
|
||||
*/
|
||||
iterator lower_bound(const key_type& __x) {
|
||||
return _M_t.lower_bound(__x);
|
||||
}
|
||||
const_iterator lower_bound(const key_type& __x) const {
|
||||
return _M_t.lower_bound(__x);
|
||||
}
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* @brief Finds the end of a subsequence matching given key.
|
||||
* @param x Key to be located.
|
||||
* @return Iterator pointing to the first element
|
||||
* greater than key, or end().
|
||||
*/
|
||||
iterator upper_bound(const key_type& __x) {
|
||||
return _M_t.upper_bound(__x);
|
||||
}
|
||||
const_iterator upper_bound(const key_type& __x) const {
|
||||
return _M_t.upper_bound(__x);
|
||||
}
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/**
|
||||
* @brief Finds a subsequence matching given key.
|
||||
* @param x Key to be located.
|
||||
* @return Pair of iterators that possibly points to the subsequence
|
||||
* matching given key.
|
||||
*
|
||||
* This function is equivalent to
|
||||
* @code
|
||||
* std::make_pair(c.lower_bound(val),
|
||||
* c.upper_bound(val))
|
||||
* @endcode
|
||||
* (but is faster than making the calls separately).
|
||||
*
|
||||
* This function probably only makes sense for multisets.
|
||||
*/
|
||||
pair<iterator,iterator> equal_range(const key_type& __x) {
|
||||
return _M_t.equal_range(__x);
|
||||
}
|
||||
pair<const_iterator,const_iterator> equal_range(const key_type& __x) const {
|
||||
return _M_t.equal_range(__x);
|
||||
}
|
||||
|
||||
template <class _K1, class _C1, class _A1>
|
||||
friend bool operator== (const multiset<_K1,_C1,_A1>&,
|
||||
const multiset<_K1,_C1,_A1>&);
|
||||
template <class _K1, class _C1, class _A1>
|
||||
friend bool operator< (const multiset<_K1,_C1,_A1>&,
|
||||
const multiset<_K1,_C1,_A1>&);
|
||||
};
|
||||
template <class _K1, class _C1, class _A1>
|
||||
friend bool
|
||||
operator< (const multiset<_K1,_C1,_A1>&,
|
||||
const multiset<_K1,_C1,_A1>&);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Multiset equality comparison.
|
||||
@ -464,7 +511,8 @@ inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
* @param y A %multiset of the same type as @a x.
|
||||
* @return True iff the size and elements of the multisets are equal.
|
||||
*
|
||||
* This is an equivalence relation. It is linear in the size of the multisets.
|
||||
* This is an equivalence relation. It is linear in the size of the
|
||||
* multisets.
|
||||
* Multisets are considered equivalent if their sizes are equal, and if
|
||||
* corresponding elements compare equal.
|
||||
*/
|
||||
@ -472,8 +520,8 @@ inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
inline bool
|
||||
operator==(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
const multiset<_Key,_Compare,_Alloc>& __y)
|
||||
{ return __x._M_t == __y._M_t; }
|
||||
|
||||
{ return __x._M_t == __y._M_t; }
|
||||
|
||||
/**
|
||||
* @brief Multiset ordering relation.
|
||||
* @param x A %multiset.
|
||||
@ -489,42 +537,42 @@ inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
inline bool
|
||||
operator<(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
const multiset<_Key,_Compare,_Alloc>& __y)
|
||||
{ return __x._M_t < __y._M_t; }
|
||||
{ return __x._M_t < __y._M_t; }
|
||||
|
||||
/// Returns !(x == y).
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
inline bool
|
||||
operator!=(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
const multiset<_Key,_Compare,_Alloc>& __y)
|
||||
{ return !(__x == __y); }
|
||||
{ return !(__x == __y); }
|
||||
|
||||
/// Returns y < x.
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
inline bool
|
||||
operator>(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
const multiset<_Key,_Compare,_Alloc>& __y)
|
||||
{ return __y < __x; }
|
||||
{ return __y < __x; }
|
||||
|
||||
/// Returns !(y < x)
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
inline bool
|
||||
operator<=(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
const multiset<_Key,_Compare,_Alloc>& __y)
|
||||
{ return !(__y < __x); }
|
||||
{ return !(__y < __x); }
|
||||
|
||||
/// Returns !(x < y)
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
inline bool
|
||||
operator>=(const multiset<_Key,_Compare,_Alloc>& __x,
|
||||
const multiset<_Key,_Compare,_Alloc>& __y)
|
||||
{ return !(__x < __y); }
|
||||
{ return !(__x < __y); }
|
||||
|
||||
/// See std::multiset::swap().
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
inline void
|
||||
swap(multiset<_Key,_Compare,_Alloc>& __x,
|
||||
multiset<_Key,_Compare,_Alloc>& __y)
|
||||
{ __x.swap(__y); }
|
||||
{ __x.swap(__y); }
|
||||
|
||||
} // namespace __gnu_norm
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// std::rel_ops implementation -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -75,61 +75,61 @@ namespace std
|
||||
{
|
||||
namespace rel_ops
|
||||
{
|
||||
/** @namespace std::rel_ops
|
||||
* @brief The generated relational operators are sequestered here.
|
||||
*/
|
||||
/** @namespace std::rel_ops
|
||||
* @brief The generated relational operators are sequestered here.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Defines @c != for arbitrary types, in terms of @c ==.
|
||||
* @param x A thing.
|
||||
* @param y Another thing.
|
||||
* @return x != y
|
||||
*
|
||||
* This function uses @c == to determine its result.
|
||||
*/
|
||||
template <class _Tp>
|
||||
inline bool
|
||||
operator!=(const _Tp& __x, const _Tp& __y)
|
||||
{ return !(__x == __y); }
|
||||
|
||||
/**
|
||||
* @brief Defines @c != for arbitrary types, in terms of @c ==.
|
||||
* @param x A thing.
|
||||
* @param y Another thing.
|
||||
* @return x != y
|
||||
*
|
||||
* This function uses @c == to determine its result.
|
||||
*/
|
||||
template <class _Tp>
|
||||
inline bool operator!=(const _Tp& __x, const _Tp& __y) {
|
||||
return !(__x == __y);
|
||||
}
|
||||
/**
|
||||
* @brief Defines @c > for arbitrary types, in terms of @c <.
|
||||
* @param x A thing.
|
||||
* @param y Another thing.
|
||||
* @return x > y
|
||||
*
|
||||
* This function uses @c < to determine its result.
|
||||
*/
|
||||
template <class _Tp>
|
||||
inline bool
|
||||
operator>(const _Tp& __x, const _Tp& __y)
|
||||
{ return __y < __x; }
|
||||
|
||||
/**
|
||||
* @brief Defines @c > for arbitrary types, in terms of @c <.
|
||||
* @param x A thing.
|
||||
* @param y Another thing.
|
||||
* @return x > y
|
||||
*
|
||||
* This function uses @c < to determine its result.
|
||||
*/
|
||||
template <class _Tp>
|
||||
inline bool operator>(const _Tp& __x, const _Tp& __y) {
|
||||
return __y < __x;
|
||||
}
|
||||
/**
|
||||
* @brief Defines @c <= for arbitrary types, in terms of @c <.
|
||||
* @param x A thing.
|
||||
* @param y Another thing.
|
||||
* @return x <= y
|
||||
*
|
||||
* This function uses @c < to determine its result.
|
||||
*/
|
||||
template <class _Tp>
|
||||
inline bool
|
||||
operator<=(const _Tp& __x, const _Tp& __y)
|
||||
{ return !(__y < __x); }
|
||||
|
||||
/**
|
||||
* @brief Defines @c <= for arbitrary types, in terms of @c <.
|
||||
* @param x A thing.
|
||||
* @param y Another thing.
|
||||
* @return x <= y
|
||||
*
|
||||
* This function uses @c < to determine its result.
|
||||
*/
|
||||
template <class _Tp>
|
||||
inline bool operator<=(const _Tp& __x, const _Tp& __y) {
|
||||
return !(__y < __x);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Defines @c >= for arbitrary types, in terms of @c <.
|
||||
* @param x A thing.
|
||||
* @param y Another thing.
|
||||
* @return x >= y
|
||||
*
|
||||
* This function uses @c < to determine its result.
|
||||
*/
|
||||
template <class _Tp>
|
||||
inline bool operator>=(const _Tp& __x, const _Tp& __y) {
|
||||
return !(__x < __y);
|
||||
}
|
||||
/**
|
||||
* @brief Defines @c >= for arbitrary types, in terms of @c <.
|
||||
* @param x A thing.
|
||||
* @param y Another thing.
|
||||
* @return x >= y
|
||||
*
|
||||
* This function uses @c < to determine its result.
|
||||
*/
|
||||
template <class _Tp>
|
||||
inline bool
|
||||
operator>=(const _Tp& __x, const _Tp& __y)
|
||||
{ return !(__x < __y); }
|
||||
|
||||
} // namespace rel_ops
|
||||
} // namespace std
|
||||
|
@ -108,7 +108,8 @@ namespace __gnu_norm
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_class_requires(_Key, _SGIAssignableConcept)
|
||||
__glibcxx_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept)
|
||||
__glibcxx_class_requires4(_Compare, bool, _Key, _Key,
|
||||
_BinaryFunctionConcept)
|
||||
|
||||
public:
|
||||
// typedefs:
|
||||
@ -142,7 +143,8 @@ namespace __gnu_norm
|
||||
|
||||
// allocation/deallocation
|
||||
/// Default constructor creates no elements.
|
||||
set() : _M_t(_Compare(), allocator_type()) {}
|
||||
set()
|
||||
: _M_t(_Compare(), allocator_type()) {}
|
||||
|
||||
/**
|
||||
* @brief Default constructor creates no elements.
|
||||
@ -152,7 +154,7 @@ namespace __gnu_norm
|
||||
*/
|
||||
explicit set(const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) {}
|
||||
: _M_t(__comp, __a) {}
|
||||
|
||||
/**
|
||||
* @brief Builds a %set from a range.
|
||||
@ -164,9 +166,9 @@ namespace __gnu_norm
|
||||
* otherwise (where N is distance(first,last)).
|
||||
*/
|
||||
template<class _InputIterator>
|
||||
set(_InputIterator __first, _InputIterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
set(_InputIterator __first, _InputIterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
|
||||
/**
|
||||
* @brief Builds a %set from a range.
|
||||
@ -180,10 +182,11 @@ namespace __gnu_norm
|
||||
* otherwise (where N is distance(first,last)).
|
||||
*/
|
||||
template<class _InputIterator>
|
||||
set(_InputIterator __first, _InputIterator __last, const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
set(_InputIterator __first, _InputIterator __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a)
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
|
||||
/**
|
||||
* @brief Set copy constructor.
|
||||
@ -192,7 +195,8 @@ namespace __gnu_norm
|
||||
* The newly-created %set uses a copy of the allocation object used
|
||||
* by @a x.
|
||||
*/
|
||||
set(const set<_Key,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {}
|
||||
set(const set<_Key,_Compare,_Alloc>& __x)
|
||||
: _M_t(__x._M_t) { }
|
||||
|
||||
/**
|
||||
* @brief Set assignment operator.
|
||||
@ -201,7 +205,8 @@ namespace __gnu_norm
|
||||
* All the elements of @a x are copied, but unlike the copy constructor,
|
||||
* the allocator object is not copied.
|
||||
*/
|
||||
set<_Key,_Compare,_Alloc>& operator=(const set<_Key, _Compare, _Alloc>& __x)
|
||||
set<_Key,_Compare,_Alloc>&
|
||||
operator=(const set<_Key, _Compare, _Alloc>& __x)
|
||||
{
|
||||
_M_t = __x._M_t;
|
||||
return *this;
|
||||
@ -210,45 +215,66 @@ namespace __gnu_norm
|
||||
// accessors:
|
||||
|
||||
/// Returns the comparison object with which the %set was constructed.
|
||||
key_compare key_comp() const { return _M_t.key_comp(); }
|
||||
key_compare
|
||||
key_comp() const
|
||||
{ return _M_t.key_comp(); }
|
||||
/// Returns the comparison object with which the %set was constructed.
|
||||
value_compare value_comp() const { return _M_t.key_comp(); }
|
||||
value_compare
|
||||
value_comp() const
|
||||
{ return _M_t.key_comp(); }
|
||||
/// Returns the allocator object with which the %set was constructed.
|
||||
allocator_type get_allocator() const { return _M_t.get_allocator(); }
|
||||
allocator_type
|
||||
get_allocator() const
|
||||
{ return _M_t.get_allocator(); }
|
||||
|
||||
/**
|
||||
* Returns a read/write iterator that points to the first element in the
|
||||
* %set. Iteration is done in ascending order according to the keys.
|
||||
*/
|
||||
iterator begin() const { return _M_t.begin(); }
|
||||
iterator
|
||||
begin() const
|
||||
{ return _M_t.begin(); }
|
||||
|
||||
/**
|
||||
* Returns a read/write iterator that points one past the last element in
|
||||
* the %set. Iteration is done in ascending order according to the keys.
|
||||
*/
|
||||
iterator end() const { return _M_t.end(); }
|
||||
iterator
|
||||
end() const
|
||||
{ return _M_t.end(); }
|
||||
|
||||
/**
|
||||
* Returns a read/write reverse iterator that points to the last element in
|
||||
* the %set. Iteration is done in descending order according to the keys.
|
||||
* Returns a read/write reverse iterator that points to the last element
|
||||
* in the %set. Iteration is done in descending order according to the
|
||||
* keys.
|
||||
*/
|
||||
reverse_iterator rbegin() const { return _M_t.rbegin(); }
|
||||
reverse_iterator
|
||||
rbegin() const
|
||||
{ return _M_t.rbegin(); }
|
||||
|
||||
/**
|
||||
* Returns a read-only (constant) reverse iterator that points to the last
|
||||
* pair in the %map. Iteration is done in descending order according to
|
||||
* the keys.
|
||||
* Returns a read-only (constant) reverse iterator that points to the
|
||||
* last pair in the %map. Iteration is done in descending order
|
||||
* according to the keys.
|
||||
*/
|
||||
reverse_iterator rend() const { return _M_t.rend(); }
|
||||
reverse_iterator
|
||||
rend() const
|
||||
{ return _M_t.rend(); }
|
||||
|
||||
/// Returns true if the %set is empty.
|
||||
bool empty() const { return _M_t.empty(); }
|
||||
bool
|
||||
empty() const
|
||||
{ return _M_t.empty(); }
|
||||
|
||||
/// Returns the size of the %set.
|
||||
size_type size() const { return _M_t.size(); }
|
||||
size_type
|
||||
size() const
|
||||
{ return _M_t.size(); }
|
||||
|
||||
/// Returns the maximum size of the %set.
|
||||
size_type max_size() const { return _M_t.max_size(); }
|
||||
size_type
|
||||
max_size() const
|
||||
{ return _M_t.max_size(); }
|
||||
|
||||
/**
|
||||
* @brief Swaps data with another %set.
|
||||
@ -261,15 +287,17 @@ namespace __gnu_norm
|
||||
* Note that the global std::swap() function is specialized such that
|
||||
* std::swap(s1,s2) will feed to this function.
|
||||
*/
|
||||
void swap(set<_Key,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }
|
||||
void
|
||||
swap(set<_Key,_Compare,_Alloc>& __x)
|
||||
{ _M_t.swap(__x._M_t); }
|
||||
|
||||
// insert/erase
|
||||
/**
|
||||
* @brief Attempts to insert an element into the %set.
|
||||
* @param x Element to be inserted.
|
||||
* @return A pair, of which the first element is an iterator that points
|
||||
* to the possibly inserted element, and the second is a bool that
|
||||
* is true if the element was actually inserted.
|
||||
* to the possibly inserted element, and the second is a bool
|
||||
* that is true if the element was actually inserted.
|
||||
*
|
||||
* This function attempts to insert an element into the %set. A %set
|
||||
* relies on unique keys and thus an element is only inserted if it is
|
||||
@ -277,9 +305,10 @@ namespace __gnu_norm
|
||||
*
|
||||
* Insertion requires logarithmic time.
|
||||
*/
|
||||
pair<iterator,bool> insert(const value_type& __x)
|
||||
pair<iterator,bool>
|
||||
insert(const value_type& __x)
|
||||
{
|
||||
pair<typename _Rep_type::iterator, bool> __p = _M_t.insert_unique(__x);
|
||||
pair<typename _Rep_type::iterator, bool> __p = _M_t.insert_unique(__x);
|
||||
return pair<iterator, bool>(__p.first, __p.second);
|
||||
}
|
||||
|
||||
@ -302,7 +331,8 @@ namespace __gnu_norm
|
||||
*
|
||||
* Insertion requires logarithmic time (if the hint is not taken).
|
||||
*/
|
||||
iterator insert(iterator __position, const value_type& __x)
|
||||
iterator
|
||||
insert(iterator __position, const value_type& __x)
|
||||
{
|
||||
typedef typename _Rep_type::iterator _Rep_iterator;
|
||||
return _M_t.insert_unique((_Rep_iterator&)__position, __x);
|
||||
@ -317,7 +347,8 @@ namespace __gnu_norm
|
||||
* Complexity similar to that of the range constructor.
|
||||
*/
|
||||
template<class _InputIterator>
|
||||
void insert(_InputIterator __first, _InputIterator __last)
|
||||
void
|
||||
insert(_InputIterator __first, _InputIterator __last)
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
|
||||
/**
|
||||
@ -329,7 +360,8 @@ namespace __gnu_norm
|
||||
* that if the element is itself a pointer, the pointed-to memory is not
|
||||
* touched in any way. Managing the pointer is the user's responsibilty.
|
||||
*/
|
||||
void erase(iterator __position)
|
||||
void
|
||||
erase(iterator __position)
|
||||
{
|
||||
typedef typename _Rep_type::iterator _Rep_iterator;
|
||||
_M_t.erase((_Rep_iterator&)__position);
|
||||
@ -346,11 +378,13 @@ namespace __gnu_norm
|
||||
* the element is itself a pointer, the pointed-to memory is not touched
|
||||
* in any way. Managing the pointer is the user's responsibilty.
|
||||
*/
|
||||
size_type erase(const key_type& __x) { return _M_t.erase(__x); }
|
||||
size_type
|
||||
erase(const key_type& __x) { return _M_t.erase(__x); }
|
||||
|
||||
/**
|
||||
* @brief Erases a [first,last) range of elements from a %set.
|
||||
* @param first Iterator pointing to the start of the range to be erased.
|
||||
* @param first Iterator pointing to the start of the range to be
|
||||
* erased.
|
||||
* @param last Iterator pointing to the end of the range to be erased.
|
||||
*
|
||||
* This function erases a sequence of elements from a %set.
|
||||
@ -358,7 +392,8 @@ namespace __gnu_norm
|
||||
* the element is itself a pointer, the pointed-to memory is not touched
|
||||
* in any way. Managing the pointer is the user's responsibilty.
|
||||
*/
|
||||
void erase(iterator __first, iterator __last)
|
||||
void
|
||||
erase(iterator __first, iterator __last)
|
||||
{
|
||||
typedef typename _Rep_type::iterator _Rep_iterator;
|
||||
_M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last);
|
||||
@ -370,7 +405,9 @@ namespace __gnu_norm
|
||||
* pointed-to memory is not touched in any way. Managing the pointer is
|
||||
* the user's responsibilty.
|
||||
*/
|
||||
void clear() { _M_t.clear(); }
|
||||
void
|
||||
clear()
|
||||
{ _M_t.clear(); }
|
||||
|
||||
// set operations:
|
||||
|
||||
@ -382,7 +419,8 @@ namespace __gnu_norm
|
||||
* This function only makes sense for multisets; for set the result will
|
||||
* either be 0 (not present) or 1 (present).
|
||||
*/
|
||||
size_type count(const key_type& __x) const
|
||||
size_type
|
||||
count(const key_type& __x) const
|
||||
{ return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
|
||||
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
@ -399,8 +437,13 @@ namespace __gnu_norm
|
||||
* pointing to the sought after element. If unsuccessful it returns the
|
||||
* past-the-end ( @c end() ) iterator.
|
||||
*/
|
||||
iterator find(const key_type& __x) { return _M_t.find(__x); }
|
||||
const_iterator find(const key_type& __x) const { return _M_t.find(__x); }
|
||||
iterator
|
||||
find(const key_type& __x)
|
||||
{ return _M_t.find(__x); }
|
||||
|
||||
const_iterator
|
||||
find(const key_type& __x) const
|
||||
{ return _M_t.find(__x); }
|
||||
//@}
|
||||
|
||||
//@{
|
||||
@ -415,9 +458,12 @@ namespace __gnu_norm
|
||||
* pointing to the first element that has a greater value than given key
|
||||
* or end() if no such element exists.
|
||||
*/
|
||||
iterator lower_bound(const key_type& __x)
|
||||
iterator
|
||||
lower_bound(const key_type& __x)
|
||||
{ return _M_t.lower_bound(__x); }
|
||||
const_iterator lower_bound(const key_type& __x) const
|
||||
|
||||
const_iterator
|
||||
lower_bound(const key_type& __x) const
|
||||
{ return _M_t.lower_bound(__x); }
|
||||
//@}
|
||||
|
||||
@ -428,9 +474,12 @@ namespace __gnu_norm
|
||||
* @return Iterator pointing to the first element
|
||||
* greater than key, or end().
|
||||
*/
|
||||
iterator upper_bound(const key_type& __x)
|
||||
iterator
|
||||
upper_bound(const key_type& __x)
|
||||
{ return _M_t.upper_bound(__x); }
|
||||
const_iterator upper_bound(const key_type& __x) const
|
||||
|
||||
const_iterator
|
||||
upper_bound(const key_type& __x) const
|
||||
{ return _M_t.upper_bound(__x); }
|
||||
//@}
|
||||
|
||||
@ -450,16 +499,22 @@ namespace __gnu_norm
|
||||
*
|
||||
* This function probably only makes sense for multisets.
|
||||
*/
|
||||
pair<iterator,iterator> equal_range(const key_type& __x)
|
||||
pair<iterator,iterator>
|
||||
equal_range(const key_type& __x)
|
||||
{ return _M_t.equal_range(__x); }
|
||||
pair<const_iterator,const_iterator> equal_range(const key_type& __x) const
|
||||
|
||||
pair<const_iterator,const_iterator>
|
||||
equal_range(const key_type& __x) const
|
||||
{ return _M_t.equal_range(__x); }
|
||||
//@}
|
||||
|
||||
template<class _K1, class _C1, class _A1>
|
||||
friend bool operator== (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&);
|
||||
friend bool
|
||||
operator== (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&);
|
||||
|
||||
template<class _K1, class _C1, class _A1>
|
||||
friend bool operator< (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&);
|
||||
friend bool
|
||||
operator< (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&);
|
||||
};
|
||||
|
||||
|
||||
@ -508,8 +563,7 @@ namespace __gnu_norm
|
||||
inline bool
|
||||
operator>(const set<_Key,_Compare,_Alloc>& __x,
|
||||
const set<_Key,_Compare,_Alloc>& __y)
|
||||
{ return __y < __x; }
|
||||
|
||||
{ return __y < __x; }
|
||||
|
||||
/// Returns !(y < x)
|
||||
template<class _Key, class _Compare, class _Alloc>
|
||||
|
Loading…
Reference in New Issue
Block a user