本文整理汇总了C++中PVarSizeList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ PVarSizeList::push_back方法的具体用法?C++ PVarSizeList::push_back怎么用?C++ PVarSizeList::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PVarSizeList
的用法示例。
在下文中一共展示了PVarSizeList::push_back方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: VarSizeList_from_matrix
PVarSizeList VarSizeList_from_matrix(const ind_t *sizes, uint32 count,
const ind_t *j, uint32 j_size,
const ind_t *data, uint32 data_size){
PVarSizeList pset = new VarSizeList(count);
uint32 total_size = 0;
for (uint32 i=0;i<count;i++){
total_size += sizes[i];
assert(j_size >= total_size);
assert(data_size >= total_size);
pset->push_back(mul_ind_t(j, data, sizes[i]));
j += sizes[i];
data += sizes[i];
}
return pset;
}
示例3: VarSizeList_from_matrix
PVarSizeList VarSizeList_from_matrix(PVarSizeList pset,
const ind_t *sizes, uint32 count,
const ind_t *j, uint32 j_size,
const ind_t *data, uint32 data_size){
if (!pset)
pset = new VarSizeList(count);
uint32 total_size = 0;
for (uint32 i=0;i<count;i++){
total_size += sizes[i];
assert(j_size >= total_size);
assert(data_size >= total_size);
//std::cout << "adding: " << mul_ind_t(j, data, sizes[i]) << "of size" << sizes[i] << std::endl;
pset->push_back(mul_ind_t(j, data, sizes[i]));
j += sizes[i];
data += sizes[i];
}
return pset;
}