operator==,!=,<,<=,>,>=(std::set) - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# operator==,!=,<,<=,>,>=(std::set)

From cppreference.com
< cpp‎ | container‎ | set

[edit template]

template< class Key, class Compare, class Alloc > bool operator==( const set<Key,Compare,Alloc>& lhs, const set<Key,Compare,Alloc>& rhs ); | (1) |
template< class Key, class Compare, class Alloc > bool operator!=( const set<Key,Compare,Alloc>& lhs, const set<Key,Compare,Alloc>& rhs ); | (2) |
template< class Key, class Compare, class Alloc > bool operator<( const set<Key,Compare,Alloc>& lhs, const set<Key,Compare,Alloc>& rhs ); | (3) |
template< class Key, class Compare, class Alloc > bool operator<=( const set<Key,Compare,Alloc>& lhs, const set<Key,Compare,Alloc>& rhs ); | (4) |
template< class Key, class Compare, class Alloc > bool operator>( const set<Key,Compare,Alloc>& lhs, const set<Key,Compare,Alloc>& rhs ); | (5) |
template< class Key, class Compare, class Alloc > bool operator>=( const set<Key,Compare,Alloc>& lhs, const set<Key,Compare,Alloc>& rhs ); | (6) |

Compares the contents of two containers.

1-2) Checks if the contents of `lhs` and `rhs` are equal, that is, whether lhs.size() == rhs.size() and each element in `lhs` compares equal with the element in `rhs` at the same position.
3-6) Compares the contents of `lhs` and `rhs` lexicographically. The comparison is performed by a function equivalent to std::lexicographical_compare.

### [edit] Parameters

lhs, rhs | - | containers whose contents to compare
- `Key` must meet the requirements of `EqualityComparable` in order to use overloads (1-2).

### [edit] Return value

1) true if the contents of the containers are equal, false otherwise
2) true if the contents of the containers are not equal, false otherwise
3) true if the contents of the `lhs` are lexicographically less than the contents of `rhs`, false otherwise
4) true if the contents of the `lhs` are lexicographically less than or equal the contents of `rhs`, false otherwise
5) true if the contents of the `lhs` are lexicographically greater than the contents of `rhs`, false otherwise
6) true if the contents of the `lhs` are lexicographically greater than or equal the contents of `rhs`, false otherwise

### [edit] Complexity

Linear in the size of the container

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/container/set/operator_cmp&oldid=50658"