本文整理汇总了C++中DataArray::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ DataArray::resize方法的具体用法?C++ DataArray::resize怎么用?C++ DataArray::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataArray
的用法示例。
在下文中一共展示了DataArray::resize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getElement
Data& getElement(uint32_t idx)
{
if (elements.size() <= idx)
{
elements.resize(idx + 1);
}
return elements[idx];
}
示例2: EllMatrix
EllMatrix(index_t rows, index_t cols, index_t nnz_per_row)
: _rows(rows), _cols(cols), nnz_per_row(nnz_per_row) {
static constexpr auto step = align_bytes / sizeof(scalar_t);
auto aligned_rows = rows;
while (aligned_rows % step != 0) {
++aligned_rows;
}
data.resize(aligned_rows, nnz_per_row);
indices.resize(aligned_rows, nnz_per_row);
}
示例3: SortCommand
//.........这里部分代码省略.........
{
patternObj = sortvec[i].value;
}
else
{
patternObj = &(sortvals[i]);
}
if (options.get_patterns.empty())
{
values.push_back(*patternObj);
}
else
{
for (uint32 j = 0; j < options.get_patterns.size(); j++)
{
Data vo;
if (GetValueByPattern(ctx, options.get_patterns[j], *patternObj, vo) < 0)
{
DEBUG_LOG("Failed to get value by pattern for:%s", options.get_patterns[j]);
vo.Clear();
}
values.push_back(vo);
}
}
}
uint32 step = options.get_patterns.empty() ? 1 : options.get_patterns.size();
switch (options.aggregate)
{
case AGGREGATE_SUM:
case AGGREGATE_AVG:
{
DataArray result;
result.resize(step);
for (uint32 i = 0; i < result.size(); i++)
{
for (uint32 j = i; j < values.size(); j += step)
{
result[i].IncrBy(values[j]);
}
}
if (options.aggregate == AGGREGATE_AVG)
{
size_t count = values.size() / step;
for (uint32 i = 0; i < result.size(); i++)
{
result[i].SetDouble(result[i].NumberValue() / count);
}
}
values.assign(result.begin(), result.end());
break;
}
case AGGREGATE_MAX:
case AGGREGATE_MIN:
{
DataArray result;
result.resize(step);
for (uint32 i = 0; i < result.size(); i++)
{
for (uint32 j = i; j < values.size(); j += step)
{
if (result[i].IsNil())
{
result[i] = values[j];
}