本文整理汇总了C++中std::multimap::crend方法的典型用法代码示例。如果您正苦于以下问题:C++ multimap::crend方法的具体用法?C++ multimap::crend怎么用?C++ multimap::crend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::multimap
的用法示例。
在下文中一共展示了multimap::crend方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int, char**)
{
{
typedef std::pair<const int, double> V;
V ar[] =
{
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
V(2, 2),
V(3, 1),
V(3, 1.5),
V(3, 2),
V(4, 1),
V(4, 1.5),
V(4, 2),
V(5, 1),
V(5, 1.5),
V(5, 2),
V(6, 1),
V(6, 1.5),
V(6, 2),
V(7, 1),
V(7, 1.5),
V(7, 2),
V(8, 1),
V(8, 1.5),
V(8, 2)
};
std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
assert(static_cast<std::size_t>(std::distance(m.begin(), m.end())) == m.size());
assert(static_cast<std::size_t>(std::distance(m.rbegin(), m.rend())) == m.size());
std::multimap<int, double>::iterator i;
i = m.begin();
std::multimap<int, double>::const_iterator k = i;
assert(i == k);
for (int j = 1; j <= 8; ++j)
for (double d = 1; d <= 2; d += .5, ++i)
{
assert(i->first == j);
assert(i->second == d);
i->second = 2.5;
assert(i->second == 2.5);
}
}
{
typedef std::pair<const int, double> V;
V ar[] =
{
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
V(2, 2),
V(3, 1),
V(3, 1.5),
V(3, 2),
V(4, 1),
V(4, 1.5),
V(4, 2),
V(5, 1),
V(5, 1.5),
V(5, 2),
V(6, 1),
V(6, 1.5),
V(6, 2),
V(7, 1),
V(7, 1.5),
V(7, 2),
V(8, 1),
V(8, 1.5),
V(8, 2)
};
const std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
assert(static_cast<std::size_t>(std::distance(m.begin(), m.end())) == m.size());
assert(static_cast<std::size_t>(std::distance(m.cbegin(), m.cend())) == m.size());
assert(static_cast<std::size_t>(std::distance(m.rbegin(), m.rend())) == m.size());
assert(static_cast<std::size_t>(std::distance(m.crbegin(), m.crend())) == m.size());
std::multimap<int, double>::const_iterator i;
i = m.begin();
for (int j = 1; j <= 8; ++j)
for (double d = 1; d <= 2; d += .5, ++i)
{
assert(i->first == j);
assert(i->second == d);
}
}
#if TEST_STD_VER >= 11
{
typedef std::pair<const int, double> V;
V ar[] =
{
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
//.........这里部分代码省略.........