顶部运算
C++ 序列顶部运算方法接受各种序列参数,并生成如相应结果序列。
以下是可用的方法:
topMax
Sequence<T> topMax(mco_size_t n) const
返回对象序列中的前 n 个最大值。
topMin
Sequence<T> topMin(mco_size_t n) const;
返回对象序列中的前 n 个最小值。
topPosMax
Sequence<mco_seq_no_t> topPosMax(mco_size_t n) const
返回对象序列中前 n 个最大值的位置 。
topPosMin
Sequence<mco_seq_no_t> topPosMin(mco_size_t n) const
返回对象序列中前 n 个最小值的位置 。
示例
以下是一个示例代码片段:
{
mco_trans_h trans;
mco_cursor_t quote_cursor;
Quote quote;
float close;
MCO_RET rc;
...
rc = mco_trans_start(db, MCO_READ_ONLY, MCO_TRANS_FOREGROUND, &trans);
if ( MCO_S_OK == rc )
{
for (rc = mco_cursor_first(trans, "e_cursor);
rc != MCO_S_CURSOR_END;
rc = mco_cursor_next(trans, "e_cursor))
{
quote.from.cursor(trans, "e_cursor);
Sequence<float> top10Close = quote.close_iterator().topMax(10);
while (top10Close.next(close))
{
Char<MAX_SYMBOL_LEN> symbol = quote.symbol;
printf("%s: close=%.3f\n", (char*)symbol, close);
}
}
mco_trans_rollback(trans);
}
}