mirror of
https://github.com/boostorg/unordered.git
synced 2025-05-11 13:34:06 +00:00
Change insert/erase as specified in n2369, the implementation and tests.
I accidently only checked in the documentation from these changes in the last check in. This contains the rest of it. [SVN r39950]
This commit is contained in:
parent
2cdb800ec3
commit
50c629dcb0
@ -158,47 +158,32 @@ namespace boost
|
||||
base.insert(obj));
|
||||
}
|
||||
|
||||
iterator insert(iterator hint, const value_type& obj)
|
||||
iterator insert(const_iterator hint, const value_type& obj)
|
||||
{
|
||||
return iterator(base.insert(get(hint), obj));
|
||||
}
|
||||
|
||||
const_iterator insert(const_iterator hint, const value_type& obj)
|
||||
{
|
||||
return const_iterator(base.insert(get(hint), obj));
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator first, InputIterator last)
|
||||
{
|
||||
base.insert(first, last);
|
||||
}
|
||||
|
||||
iterator erase(iterator position)
|
||||
iterator erase(const_iterator position)
|
||||
{
|
||||
return iterator(base.erase(get(position)));
|
||||
}
|
||||
|
||||
const_iterator erase(const_iterator position)
|
||||
{
|
||||
return const_iterator(base.erase(get(position)));
|
||||
}
|
||||
|
||||
size_type erase(const key_type& k)
|
||||
{
|
||||
return base.erase(k);
|
||||
}
|
||||
|
||||
iterator erase(iterator first, iterator last)
|
||||
iterator erase(const_iterator first, const_iterator last)
|
||||
{
|
||||
return iterator(base.erase(get(first), get(last)));
|
||||
}
|
||||
|
||||
const_iterator erase(const_iterator first, const_iterator last)
|
||||
{
|
||||
return const_iterator(base.erase(get(first), get(last)));
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
base.clear();
|
||||
@ -477,47 +462,32 @@ namespace boost
|
||||
return iterator(base.insert(obj));
|
||||
}
|
||||
|
||||
iterator insert(iterator hint, const value_type& obj)
|
||||
iterator insert(const_iterator hint, const value_type& obj)
|
||||
{
|
||||
return iterator(base.insert(get(hint), obj));
|
||||
}
|
||||
|
||||
const_iterator insert(const_iterator hint, const value_type& obj)
|
||||
{
|
||||
return const_iterator(base.insert(get(hint), obj));
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator first, InputIterator last)
|
||||
{
|
||||
base.insert(first, last);
|
||||
}
|
||||
|
||||
iterator erase(iterator position)
|
||||
iterator erase(const_iterator position)
|
||||
{
|
||||
return iterator(base.erase(get(position)));
|
||||
}
|
||||
|
||||
const_iterator erase(const_iterator position)
|
||||
{
|
||||
return const_iterator(base.erase(get(position)));
|
||||
}
|
||||
|
||||
size_type erase(const key_type& k)
|
||||
{
|
||||
return base.erase(k);
|
||||
}
|
||||
|
||||
iterator erase(iterator first, iterator last)
|
||||
iterator erase(const_iterator first, const_iterator last)
|
||||
{
|
||||
return iterator(base.erase(get(first), get(last)));
|
||||
}
|
||||
|
||||
const_iterator erase(const_iterator first, const_iterator last)
|
||||
{
|
||||
return const_iterator(base.erase(get(first), get(last)));
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
base.clear();
|
||||
|
@ -155,9 +155,9 @@ namespace boost
|
||||
base.insert(obj));
|
||||
}
|
||||
|
||||
const_iterator insert(const_iterator hint, const value_type& obj)
|
||||
iterator insert(const_iterator hint, const value_type& obj)
|
||||
{
|
||||
return const_iterator(base.insert(get(hint), obj));
|
||||
return iterator(base.insert(get(hint), obj));
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
@ -166,9 +166,9 @@ namespace boost
|
||||
base.insert(first, last);
|
||||
}
|
||||
|
||||
const_iterator erase(const_iterator position)
|
||||
iterator erase(const_iterator position)
|
||||
{
|
||||
return const_iterator(base.erase(get(position)));
|
||||
return iterator(base.erase(get(position)));
|
||||
}
|
||||
|
||||
size_type erase(const key_type& k)
|
||||
@ -176,9 +176,9 @@ namespace boost
|
||||
return base.erase(k);
|
||||
}
|
||||
|
||||
const_iterator erase(const_iterator first, const_iterator last)
|
||||
iterator erase(const_iterator first, const_iterator last)
|
||||
{
|
||||
return const_iterator(base.erase(get(first), get(last)));
|
||||
return iterator(base.erase(get(first), get(last)));
|
||||
}
|
||||
|
||||
void clear()
|
||||
@ -439,9 +439,9 @@ namespace boost
|
||||
return iterator(base.insert(obj));
|
||||
}
|
||||
|
||||
const_iterator insert(const_iterator hint, const value_type& obj)
|
||||
iterator insert(const_iterator hint, const value_type& obj)
|
||||
{
|
||||
return const_iterator(base.insert(get(hint), obj));
|
||||
return iterator(base.insert(get(hint), obj));
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
@ -450,9 +450,9 @@ namespace boost
|
||||
base.insert(first, last);
|
||||
}
|
||||
|
||||
const_iterator erase(const_iterator position)
|
||||
iterator erase(const_iterator position)
|
||||
{
|
||||
return const_iterator(base.erase(get(position)));
|
||||
return iterator(base.erase(get(position)));
|
||||
}
|
||||
|
||||
size_type erase(const key_type& k)
|
||||
@ -460,9 +460,9 @@ namespace boost
|
||||
return base.erase(k);
|
||||
}
|
||||
|
||||
const_iterator erase(const_iterator first, const_iterator last)
|
||||
iterator erase(const_iterator first, const_iterator last)
|
||||
{
|
||||
return const_iterator(base.erase(get(first), get(last)));
|
||||
return iterator(base.erase(get(first), get(last)));
|
||||
}
|
||||
|
||||
void clear()
|
||||
|
@ -125,9 +125,9 @@ namespace minimal
|
||||
{
|
||||
friend class allocator<T>;
|
||||
|
||||
T* ptr_;
|
||||
T const* ptr_;
|
||||
|
||||
const_ptr(T* ptr) : ptr_(ptr) {}
|
||||
const_ptr(T const* ptr) : ptr_(ptr) {}
|
||||
public:
|
||||
const_ptr() : ptr_(0) {}
|
||||
const_ptr(ptr<T> const& x) : ptr_(x.ptr_) {}
|
||||
@ -135,12 +135,12 @@ namespace minimal
|
||||
typedef void (const_ptr::*bool_type)() const;
|
||||
void this_type_does_not_support_comparisons() const {}
|
||||
|
||||
T& operator*() const { return *ptr_; }
|
||||
T* operator->() const { return ptr_; }
|
||||
T const& operator*() const { return *ptr_; }
|
||||
T const* operator->() const { return ptr_; }
|
||||
const_ptr& operator++() { ++ptr_; return *this; }
|
||||
const_ptr operator++(int) { const_ptr tmp(*this); ++ptr_; return tmp; }
|
||||
const_ptr operator+(int s) const { return const_ptr(ptr_ + s); }
|
||||
T& operator[](int s) const { return ptr_[s]; }
|
||||
T const& operator[](int s) const { return ptr_[s]; }
|
||||
bool operator!() const { return !ptr_; }
|
||||
|
||||
operator bool_type() const {
|
||||
|
@ -144,10 +144,8 @@ void unordered_test(X&, Key& k, T& t, Hash& hf, Pred& eq)
|
||||
test::check_return_type<hasher>::equals(b.hash_function());
|
||||
test::check_return_type<key_equal>::equals(b.key_eq());
|
||||
|
||||
iterator q = a.begin();
|
||||
const_iterator r = a.begin();
|
||||
const_iterator q = a.cbegin();
|
||||
test::check_return_type<iterator>::equals(a.insert(q, t));
|
||||
test::check_return_type<const_iterator>::equals(a.insert(r, t));
|
||||
|
||||
// TODO: void return?
|
||||
a.insert(i, j);
|
||||
@ -156,23 +154,13 @@ void unordered_test(X&, Key& k, T& t, Hash& hf, Pred& eq)
|
||||
BOOST_TEST(a.empty());
|
||||
if(a.empty()) {
|
||||
a.insert(t);
|
||||
q = a.begin();
|
||||
q = a.cbegin();
|
||||
test::check_return_type<iterator>::equals(a.erase(q));
|
||||
}
|
||||
|
||||
BOOST_TEST(a.empty());
|
||||
if(a.empty()) {
|
||||
a.insert(t);
|
||||
r = a.begin();
|
||||
test::check_return_type<const_iterator>::equals(a.erase(r));
|
||||
}
|
||||
|
||||
iterator q1 = a.begin(), q2 = a.end();
|
||||
const_iterator q1 = a.cbegin(), q2 = a.cend();
|
||||
test::check_return_type<iterator>::equals(a.erase(q1, q2));
|
||||
|
||||
const_iterator r1 = a.begin(), r2 = a.end();
|
||||
test::check_return_type<const_iterator>::equals(a.erase(r1, r2));
|
||||
|
||||
// TODO: void return?
|
||||
a.clear();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user