| (1) | template <class T, class Compare, class Allocator> bool operator== ( const multiset<T,Compare,Allocator>& lhs, const multiset<T,Compare,Allocator>& rhs ); |
|---|---|
| (2) | template <class T, class Compare, class Allocator> bool operator!= ( const multiset<T,Compare,Allocator>& lhs, const multiset<T,Compare,Allocator>& rhs ); |
| (3) | template <class T, class Compare, class Allocator> bool operator< ( const multiset<T,Compare,Allocator>& lhs, const multiset<T,Compare,Allocator>& rhs ); |
| (4) | template <class T, class Compare, class Allocator> bool operator<= ( const multiset<T,Compare,Allocator>& lhs, const multiset<T,Compare,Allocator>& rhs ); |
| (5) | template <class T, class Compare, class Allocator> bool operator> ( const multiset<T,Compare,Allocator>& lhs, const multiset<T,Compare,Allocator>& rhs ); |
| (6) | template <class T, class Compare, class Allocator> bool operator>= ( const multiset<T,Compare,Allocator>& lhs, const multiset<T,Compare,Allocator>& rhs ); |
operator==) is performed by first comparing sizes , and if they match, the elements are compared sequentially using operator==, stopping at the first mismatch (as if using algorithm equal ).operator<) behaves as if using algorithm lexicographical_compare , which compares the elements sequentially using operator< in a reciprocal manner (i.e., checking both a<b and b<a) and stopping at the first occurrence.== and < internally to compare the elements, behaving as if the following equivalent operations were performed:| operation | equivalent operation |
|---|---|
a!=b | !(a==b) |
a>b | b<a |
a<=b | !(b<a) |
a>=b | !(a<b) |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// multiset comparisons
#include <iostream>
#include <set>
int main ()
{
std::multiset<int> foo,bar;
foo.insert(10);
bar.insert(20);
bar.insert(20);
foo.insert(30);
// foo ({10,30}) vs bar ({20,20}):
if (foo==bar) std::cout << "foo and bar are equal\n";
if (foo!=bar) std::cout << "foo and bar are not equal\n";
if (foo< bar) std::cout << "foo is less than bar\n";
if (foo> bar) std::cout << "foo is greater than bar\n";
if (foo<=bar) std::cout << "foo is less than or equal to bar\n";
if (foo>=bar) std::cout << "foo is greater than or equal to bar\n";
return 0;
}
foo and bar are not equal foo is less than bar foo is less than or equal to bar