本文整理汇总了C++中std::multiset::cend方法的典型用法代码示例。如果您正苦于以下问题:C++ multiset::cend方法的具体用法?C++ multiset::cend怎么用?C++ multiset::cend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::multiset
的用法示例。
在下文中一共展示了multiset::cend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: total_receipt
double Basket::total_receipt(ostream &os) const
{
double sum = 0.0;
for (auto iter = items.cbegin();
iter != items.cend();
iter = items.upper_bound(*iter)) {
sum += print_total(os, **iter, items.count(*iter));
}
os << "Total Sale: " << sum << endl;
return sum;
}
示例2: main
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());
std::multiset<int>::iterator i;
i = m.begin();
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());
std::multiset<int, double>::const_iterator i;
i = m.begin();
for (int j = 1; j <= 8; ++j)
for (int k = 0; k < 3; ++k, ++i)
assert(*i == j);
}
}