Document comparison operators for non tree associative containers.

This commit is contained in:
Ion Gaztañaga
2014-01-03 12:43:03 +01:00
parent 4dc3df6b6b
commit 2489010881
6 changed files with 252 additions and 84 deletions

View File

@@ -1537,24 +1537,45 @@ class deque : protected deque_base<Allocator>
this->members_.m_finish = this->members_.m_start; this->members_.m_finish = this->members_.m_start;
} }
//! <b>Effects</b>: Returns true if x and y are equal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const deque& x, const deque& y) friend bool operator==(const deque& x, const deque& y)
{ return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); } { return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); }
//! <b>Effects</b>: Returns true if x and y are unequal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator!=(const deque& x, const deque& y) friend bool operator!=(const deque& x, const deque& y)
{ return !(x == y); } { return !(x == y); }
//! <b>Effects</b>: Returns true if x is less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const deque& x, const deque& y) friend bool operator<(const deque& x, const deque& 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()); }
//! <b>Effects</b>: Returns true if x is greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>(const deque& x, const deque& y) friend bool operator>(const deque& x, const deque& y)
{ return y < x; } { return y < x; }
friend bool operator>=(const deque& x, const deque& y)
{ return !(x < y); }
//! <b>Effects</b>: Returns true if x is equal or less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<=(const deque& x, const deque& y) friend bool operator<=(const deque& x, const deque& y)
{ return !(y < x); } { return !(y < x); }
//! <b>Effects</b>: Returns true if x is equal or greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>=(const deque& x, const deque& y)
{ return !(x < y); }
//! <b>Effects</b>: x.swap(y)
//!
//! <b>Complexity</b>: Constant.
friend void swap(deque& x, deque& y) friend void swap(deque& x, deque& y)
{ x.swap(y); } { x.swap(y); }

View File

@@ -859,26 +859,47 @@ class flat_map
std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const
{ return container_detail::force_copy<std::pair<const_iterator,const_iterator> >(m_flat_tree.equal_range(x)); } { return container_detail::force_copy<std::pair<const_iterator,const_iterator> >(m_flat_tree.equal_range(x)); }
//! <b>Effects</b>: Returns true if x and y are equal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const flat_map& x, const flat_map& y) friend bool operator==(const flat_map& x, const flat_map& y)
{ return x.m_flat_tree == y.m_flat_tree; } { return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); }
friend bool operator<(const flat_map& x, const flat_map& y)
{ return x.m_flat_tree < y.m_flat_tree; }
//! <b>Effects</b>: Returns true if x and y are unequal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator!=(const flat_map& x, const flat_map& y) friend bool operator!=(const flat_map& x, const flat_map& y)
{ return !(x == y); } { return !(x == y); }
//! <b>Effects</b>: Returns true if x is less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const flat_map& x, const flat_map& y)
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
//! <b>Effects</b>: Returns true if x is greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>(const flat_map& x, const flat_map& y) friend bool operator>(const flat_map& x, const flat_map& y)
{ return y < x; } { return y < x; }
//! <b>Effects</b>: Returns true if x is equal or less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<=(const flat_map& x, const flat_map& y) friend bool operator<=(const flat_map& x, const flat_map& y)
{ return !(y < x); } { return !(y < x); }
//! <b>Effects</b>: Returns true if x is equal or greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>=(const flat_map& x, const flat_map& y) friend bool operator>=(const flat_map& x, const flat_map& y)
{ return !(x < y); } { return !(x < y); }
//! <b>Effects</b>: x.swap(y)
//!
//! <b>Complexity</b>: Constant.
friend void swap(flat_map& x, flat_map& y) friend void swap(flat_map& x, flat_map& y)
{ x.swap(y); } { x.swap(y); }
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
private: private:
@@ -1651,26 +1672,47 @@ class flat_multimap
std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const std::pair<const_iterator,const_iterator> equal_range(const key_type& x) const
{ return container_detail::force_copy<std::pair<const_iterator,const_iterator> >(m_flat_tree.equal_range(x)); } { return container_detail::force_copy<std::pair<const_iterator,const_iterator> >(m_flat_tree.equal_range(x)); }
//! <b>Effects</b>: Returns true if x and y are equal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const flat_multimap& x, const flat_multimap& y) friend bool operator==(const flat_multimap& x, const flat_multimap& y)
{ return x.m_flat_tree == y.m_flat_tree; } { return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); }
friend bool operator<(const flat_multimap& x, const flat_multimap& y)
{ return x.m_flat_tree < y.m_flat_tree; }
//! <b>Effects</b>: Returns true if x and y are unequal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator!=(const flat_multimap& x, const flat_multimap& y) friend bool operator!=(const flat_multimap& x, const flat_multimap& y)
{ return !(x == y); } { return !(x == y); }
//! <b>Effects</b>: Returns true if x is less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const flat_multimap& x, const flat_multimap& y)
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
//! <b>Effects</b>: Returns true if x is greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>(const flat_multimap& x, const flat_multimap& y) friend bool operator>(const flat_multimap& x, const flat_multimap& y)
{ return y < x; } { return y < x; }
//! <b>Effects</b>: Returns true if x is equal or less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<=(const flat_multimap& x, const flat_multimap& y) friend bool operator<=(const flat_multimap& x, const flat_multimap& y)
{ return !(y < x); } { return !(y < x); }
//! <b>Effects</b>: Returns true if x is equal or greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>=(const flat_multimap& x, const flat_multimap& y) friend bool operator>=(const flat_multimap& x, const flat_multimap& y)
{ return !(x < y); } { return !(x < y); }
//! <b>Effects</b>: x.swap(y)
//!
//! <b>Complexity</b>: Constant.
friend void swap(flat_multimap& x, flat_multimap& y) friend void swap(flat_multimap& x, flat_multimap& y)
{ x.swap(y); } { x.swap(y); }
}; };
}} }}

View File

@@ -659,26 +659,47 @@ class flat_set
std::pair<iterator,iterator> equal_range(const key_type& x) std::pair<iterator,iterator> equal_range(const key_type& x)
{ return m_flat_tree.equal_range(x); } { return m_flat_tree.equal_range(x); }
//! <b>Effects</b>: Returns true if x and y are equal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const flat_set& x, const flat_set& y) friend bool operator==(const flat_set& x, const flat_set& y)
{ return x.m_flat_tree == y.m_flat_tree; } { return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); }
friend bool operator<(const flat_set& x, const flat_set& y)
{ return x.m_flat_tree < y.m_flat_tree; }
//! <b>Effects</b>: Returns true if x and y are unequal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator!=(const flat_set& x, const flat_set& y) friend bool operator!=(const flat_set& x, const flat_set& y)
{ return !(x == y); } { return !(x == y); }
//! <b>Effects</b>: Returns true if x is less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const flat_set& x, const flat_set& y)
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
//! <b>Effects</b>: Returns true if x is greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>(const flat_set& x, const flat_set& y) friend bool operator>(const flat_set& x, const flat_set& y)
{ return y < x; } { return y < x; }
//! <b>Effects</b>: Returns true if x is equal or less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<=(const flat_set& x, const flat_set& y) friend bool operator<=(const flat_set& x, const flat_set& y)
{ return !(y < x); } { return !(y < x); }
//! <b>Effects</b>: Returns true if x is equal or greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>=(const flat_set& x, const flat_set& y) friend bool operator>=(const flat_set& x, const flat_set& y)
{ return !(x < y); } { return !(x < y); }
//! <b>Effects</b>: x.swap(y)
//!
//! <b>Complexity</b>: Constant.
friend void swap(flat_set& x, flat_set& y) friend void swap(flat_set& x, flat_set& y)
{ x.swap(y); } { x.swap(y); }
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
private: private:
@@ -1299,26 +1320,47 @@ class flat_multiset
std::pair<iterator,iterator> equal_range(const key_type& x) std::pair<iterator,iterator> equal_range(const key_type& x)
{ return m_flat_tree.equal_range(x); } { return m_flat_tree.equal_range(x); }
//! <b>Effects</b>: Returns true if x and y are equal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const flat_multiset& x, const flat_multiset& y) friend bool operator==(const flat_multiset& x, const flat_multiset& y)
{ return x.m_flat_tree == y.m_flat_tree; } { return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); }
friend bool operator<(const flat_multiset& x, const flat_multiset& y)
{ return x.m_flat_tree < y.m_flat_tree; }
//! <b>Effects</b>: Returns true if x and y are unequal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator!=(const flat_multiset& x, const flat_multiset& y) friend bool operator!=(const flat_multiset& x, const flat_multiset& y)
{ return !(x == y); } { return !(x == y); }
//! <b>Effects</b>: Returns true if x is less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const flat_multiset& x, const flat_multiset& y)
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
//! <b>Effects</b>: Returns true if x is greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>(const flat_multiset& x, const flat_multiset& y) friend bool operator>(const flat_multiset& x, const flat_multiset& y)
{ return y < x; } { return y < x; }
//! <b>Effects</b>: Returns true if x is equal or less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<=(const flat_multiset& x, const flat_multiset& y) friend bool operator<=(const flat_multiset& x, const flat_multiset& y)
{ return !(y < x); } { return !(y < x); }
//! <b>Effects</b>: Returns true if x is equal or greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>=(const flat_multiset& x, const flat_multiset& y) friend bool operator>=(const flat_multiset& x, const flat_multiset& y)
{ return !(x < y); } { return !(x < y); }
//! <b>Effects</b>: x.swap(y)
//!
//! <b>Complexity</b>: Constant.
friend void swap(flat_multiset& x, flat_multiset& y) friend void swap(flat_multiset& x, flat_multiset& y)
{ x.swap(y); } { x.swap(y); }
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
private: private:

View File

@@ -1216,6 +1216,9 @@ class list
void reverse() BOOST_CONTAINER_NOEXCEPT void reverse() BOOST_CONTAINER_NOEXCEPT
{ this->icont().reverse(); } { this->icont().reverse(); }
//! <b>Effects</b>: Returns true if x and y are equal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const list& x, const list& y) friend bool operator==(const list& x, const list& y)
{ {
if(x.size() != y.size()){ if(x.size() != y.size()){
@@ -1233,21 +1236,39 @@ class list
return i1 == end1; return i1 == end1;
} }
friend bool operator<(const list& x, const list& y) //! <b>Effects</b>: Returns true if x and y are unequal
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } //!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator!=(const list& x, const list& y) friend bool operator!=(const list& x, const list& y)
{ return !(x == y); } { return !(x == y); }
//! <b>Effects</b>: Returns true if x is less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const list& x, const list& y)
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
//! <b>Effects</b>: Returns true if x is greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>(const list& x, const list& y) friend bool operator>(const list& x, const list& y)
{ return y < x; } { return y < x; }
//! <b>Effects</b>: Returns true if x is equal or less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<=(const list& x, const list& y) friend bool operator<=(const list& x, const list& y)
{ return !(y < x); } { return !(y < x); }
//! <b>Effects</b>: Returns true if x is equal or greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>=(const list& x, const list& y) friend bool operator>=(const list& x, const list& y)
{ return !(x < y); } { return !(x < y); }
//! <b>Effects</b>: x.swap(y)
//!
//! <b>Complexity</b>: Constant.
friend void swap(list& x, list& y) friend void swap(list& x, list& y)
{ x.swap(y); } { x.swap(y); }

View File

@@ -1510,25 +1510,46 @@ class stable_vector
void clear() BOOST_CONTAINER_NOEXCEPT void clear() BOOST_CONTAINER_NOEXCEPT
{ this->erase(this->cbegin(),this->cend()); } { this->erase(this->cbegin(),this->cend()); }
friend bool operator==(const stable_vector& x,const stable_vector& y) //! <b>Effects</b>: Returns true if x and y are equal
{ return x.size()==y.size()&&std::equal(x.begin(),x.end(),y.begin()); } //!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const stable_vector& x, const stable_vector& y)
{ return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); }
friend bool operator< (const stable_vector& x,const stable_vector& y) //! <b>Effects</b>: Returns true if x and y are unequal
{ return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); } //!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator!=(const stable_vector& x, const stable_vector& y)
{ return !(x == y); }
friend bool operator!=(const stable_vector& x,const stable_vector& y) //! <b>Effects</b>: Returns true if x is less than y
{ return !(x==y); } //!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const stable_vector& x, const stable_vector& y)
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
friend bool operator> (const stable_vector& x,const stable_vector& y) //! <b>Effects</b>: Returns true if x is greater than y
{ return y<x; } //!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>(const stable_vector& x, const stable_vector& y)
{ return y < x; }
friend bool operator>=(const stable_vector& x,const stable_vector& y) //! <b>Effects</b>: Returns true if x is equal or less than y
{ return !(x<y); } //!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<=(const stable_vector& x, const stable_vector& y)
{ return !(y < x); }
friend bool operator<=(const stable_vector& x,const stable_vector& y) //! <b>Effects</b>: Returns true if x is equal or greater than y
{ return !(x>y); } //!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>=(const stable_vector& x, const stable_vector& y)
{ return !(x < y); }
friend void swap(stable_vector& x,stable_vector& y) //! <b>Effects</b>: x.swap(y)
//!
//! <b>Complexity</b>: Constant.
friend void swap(stable_vector& x, stable_vector& y)
{ x.swap(y); } { x.swap(y); }
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED

View File

@@ -1564,10 +1564,52 @@ class vector
//! //!
//! <b>Throws</b>: Nothing. //! <b>Throws</b>: Nothing.
//! //!
//! <b>Complexity</b>: Linear to the number of elements in the vector. //! <b>Complexity</b>: Linear to the number of elements in the container.
void clear() BOOST_CONTAINER_NOEXCEPT void clear() BOOST_CONTAINER_NOEXCEPT
{ this->priv_destroy_all(); } { this->priv_destroy_all(); }
//! <b>Effects</b>: Returns true if x and y are equal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const vector& x, const vector& y)
{ return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); }
//! <b>Effects</b>: Returns true if x and y are unequal
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator!=(const vector& x, const vector& y)
{ return !(x == y); }
//! <b>Effects</b>: Returns true if x is less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const vector& x, const vector& y)
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
//! <b>Effects</b>: Returns true if x is greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>(const vector& x, const vector& y)
{ return y < x; }
//! <b>Effects</b>: Returns true if x is equal or less than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<=(const vector& x, const vector& y)
{ return !(y < x); }
//! <b>Effects</b>: Returns true if x is equal or greater than y
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator>=(const vector& x, const vector& y)
{ return !(x < y); }
//! <b>Effects</b>: x.swap(y)
//!
//! <b>Complexity</b>: Constant.
friend void swap(vector& x, vector& y)
{ x.swap(y); }
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
//Absolutely experimental. This function might change, disappear or simply crash! //Absolutely experimental. This function might change, disappear or simply crash!
@@ -1586,27 +1628,6 @@ class vector
this->priv_insert_ordered_at(element_count, last_position_it, true, last_skip_it, last_value_it); this->priv_insert_ordered_at(element_count, last_position_it, true, last_skip_it, last_value_it);
} }
friend bool operator==(const vector& x, const vector& y)
{ return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); }
friend bool operator!=(const vector& x, const vector& y)
{ return !(x == y); }
friend bool operator<(const vector& x, const vector& y)
{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
friend bool operator>(const vector& x, const vector& y)
{ return y < x; }
friend bool operator<=(const vector& x, const vector& y)
{ return !(y < x); }
friend bool operator>=(const vector& x, const vector& y)
{ return !(x < y); }
friend void swap(vector& x, vector& y)
{ x.swap(y); }
private: private:
template<class OtherAllocator, class AllocVersion> template<class OtherAllocator, class AllocVersion>