本文整理汇总了C++中PVarSizeList::has_ind方法的典型用法代码示例。如果您正苦于以下问题:C++ PVarSizeList::has_ind方法的具体用法?C++ PVarSizeList::has_ind怎么用?C++ PVarSizeList::has_ind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PVarSizeList
的用法示例。
在下文中一共展示了PVarSizeList::has_ind方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetIndexSet
PVarSizeList GetIndexSet(PVarSizeList pRet,
const PProfitCalculator profCalc,
double max_prof,
double **p_profits) {
ind_t max_d = profCalc->max_dim();
ind_mul_ind_t ind_set;
ind_set.push_back(setprof_t(mul_ind_t(), profCalc->calc_log_prof(mul_ind_t())));
double cur_prof;
ind_mul_ind_t::iterator itrCur = ind_set.begin();
while (itrCur != ind_set.end()) {
if (itrCur->size < max_d) {
mul_ind_t cur_ind = itrCur->ind;
ind_set.push_back(setprof_t(cur_ind, -1, itrCur->size+1));
ind_t cur_size = itrCur->size;
cur_ind.step(cur_size);
while ((cur_prof=profCalc->calc_log_prof(cur_ind)) <= max_prof){
ind_set.push_back(setprof_t(cur_ind, cur_prof));
cur_ind.step(cur_size);
}
// if (added > 0) // This assumes that dimensions are ordered!
}
// If this iterator has negative profit it means it's temporary and
// can be deleted safely (since all derivatives are already added)
if (itrCur->profit < 0)
itrCur = ind_set.erase(itrCur); // erase returns the next iterator
else
itrCur++;
}
ind_set.sort(compare_setprof);
if (p_profits)
*p_profits = static_cast<double*>(malloc(sizeof(double) * ind_set.size()));
uint32 i=0;
if (!pRet)
pRet = new VarSizeList(ind_set.size());
for (auto itr=ind_set.begin();itr!=ind_set.end();itr++){
if (!pRet->has_ind(itr->ind))
pRet->push_back(itr->ind);
if (p_profits)
(*p_profits)[i++] = itr->profit;
}
return pRet;
}