本文整理汇总了C++中std::multiset::upper_bound方法的典型用法代码示例。如果您正苦于以下问题:C++ multiset::upper_bound方法的具体用法?C++ multiset::upper_bound怎么用?C++ multiset::upper_bound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::multiset
的用法示例。
在下文中一共展示了multiset::upper_bound方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: total
double Basket::total() const
{
double sum = 0.0;
for(const_iter i = items.begin() ; i != items.end() ; i = items.upper_bound(*i))
{
sum += (*i)->net_price(items.count(*i));
}
return sum;
}
示例3: Qw
inline void converter<point_t>::knot_insertion(point_container_t& P,
std::multiset<value_type>& knots,
std::size_t order,
value_type t) const {
typedef typename point_t::value_type value_type;
// copy knotvector for subscript [] access
std::vector<value_type> kv_cpy(knots.begin(), knots.end());
// get parameter
std::size_t p = order - 1; // degree
std::size_t s = knots.count(t); // multiplicity
std::size_t r = std::max(std::size_t(0), p - s); // number of insertions
// get knotspan
std::size_t k = std::distance(knots.begin(), knots.upper_bound(t));
std::size_t np = P.size(); // number of control points
// start computation
std::size_t nq = np + r;
// helper arrays
std::vector<point_t> Qw(nq);
std::vector<point_t> Rw(p - s + 1);
// copy unaffected points and transform into homogenous coords
for (size_t i = 0; i <= k - p; ++i) {
Qw[i] = P[i].as_homogenous();
}
for (size_t i = k - s - 1; i <= np - 1; ++i) {
Qw[i + r] = P[i].as_homogenous();
}
// helper points
for (size_t i = 0; i <= p - s; ++i) {
Rw[i] = P[k - p + i - 1].as_homogenous();
}
// do knot insertion itself
std::size_t L = 0;
for (std::size_t j = 1; j <= r; ++j) {
L = k - p + j;
for (std::size_t i = 0; i <= p - j - s; ++i) {
value_type alpha =
(t - kv_cpy[L + i - 1]) / (kv_cpy[i + k] - kv_cpy[L + i - 1]);
Rw[i] = alpha * Rw[i + 1] + value_type(1.0 - alpha) * Rw[i];
}
Qw[L - 1] = Rw[0];
Qw[k + r - j - s - 1] = Rw[p - j - s];
}
// insert knots
for (std::size_t i = 0; i < r; ++i) {
knots.insert(t);
}
// copy new control points
P.clear();
// transform back to euclidian space
for (typename std::vector<point_t>::iterator i = Qw.begin(); i != Qw.end();
++i) {
P.push_back((*i).as_euclidian());
}
}