2010-05-11 21:42:16 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2010-05-11 23:36:01 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
2010-05-11 21:42:16 +02:00
|
|
|
//
|
2010-11-16 23:09:02 +01:00
|
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
|
|
// Source Licenses. See LICENSE.TXT for details.
|
2010-05-11 21:42:16 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// <set>
|
|
|
|
|
|
|
|
// class multiset
|
|
|
|
|
|
|
|
// iterator begin();
|
|
|
|
// const_iterator begin() const;
|
|
|
|
// iterator end();
|
|
|
|
// const_iterator end() const;
|
2010-08-22 02:15:28 +02:00
|
|
|
//
|
2010-05-11 21:42:16 +02:00
|
|
|
// reverse_iterator rbegin();
|
|
|
|
// const_reverse_iterator rbegin() const;
|
|
|
|
// reverse_iterator rend();
|
|
|
|
// const_reverse_iterator rend() const;
|
2010-08-22 02:15:28 +02:00
|
|
|
//
|
2010-05-11 21:42:16 +02:00
|
|
|
// const_iterator cbegin() const;
|
|
|
|
// const_iterator cend() const;
|
|
|
|
// const_reverse_iterator crbegin() const;
|
|
|
|
// const_reverse_iterator crend() const;
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
typedef int V;
|
|
|
|
V ar[] =
|
|
|
|
{
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
2,
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
3,
|
|
|
|
3,
|
|
|
|
4,
|
|
|
|
4,
|
|
|
|
4,
|
|
|
|
5,
|
|
|
|
5,
|
|
|
|
5,
|
|
|
|
6,
|
|
|
|
6,
|
|
|
|
6,
|
|
|
|
7,
|
|
|
|
7,
|
|
|
|
7,
|
|
|
|
8,
|
|
|
|
8,
|
|
|
|
8
|
|
|
|
};
|
|
|
|
std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
|
|
|
assert(std::distance(m.begin(), m.end()) == m.size());
|
|
|
|
assert(std::distance(m.rbegin(), m.rend()) == m.size());
|
2011-01-29 00:46:28 +01:00
|
|
|
std::multiset<int>::iterator i;
|
|
|
|
i = m.begin();
|
2010-05-11 21:42:16 +02:00
|
|
|
std::multiset<int>::const_iterator k = i;
|
|
|
|
assert(i == k);
|
|
|
|
for (int j = 1; j <= 8; ++j)
|
|
|
|
for (int k = 0; k < 3; ++k, ++i)
|
|
|
|
assert(*i == j);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
typedef int V;
|
|
|
|
V ar[] =
|
|
|
|
{
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
2,
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
3,
|
|
|
|
3,
|
|
|
|
4,
|
|
|
|
4,
|
|
|
|
4,
|
|
|
|
5,
|
|
|
|
5,
|
|
|
|
5,
|
|
|
|
6,
|
|
|
|
6,
|
|
|
|
6,
|
|
|
|
7,
|
|
|
|
7,
|
|
|
|
7,
|
|
|
|
8,
|
|
|
|
8,
|
|
|
|
8
|
|
|
|
};
|
|
|
|
const std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
|
|
|
assert(std::distance(m.begin(), m.end()) == m.size());
|
|
|
|
assert(std::distance(m.cbegin(), m.cend()) == m.size());
|
|
|
|
assert(std::distance(m.rbegin(), m.rend()) == m.size());
|
|
|
|
assert(std::distance(m.crbegin(), m.crend()) == m.size());
|
2011-01-29 00:46:28 +01:00
|
|
|
std::multiset<int, double>::const_iterator i;
|
|
|
|
i = m.begin();
|
2010-05-11 21:42:16 +02:00
|
|
|
for (int j = 1; j <= 8; ++j)
|
|
|
|
for (int k = 0; k < 3; ++k, ++i)
|
|
|
|
assert(*i == j);
|
|
|
|
}
|
|
|
|
}
|