运行长度加密序列函数
运行长度加密(Run Length Encryption, RLE) C 序列函数接受多种输入参数,并生成如下面表格中所述的结果序列或标量类型:
rle_count
mco_seq_rle_count()
返回当前迭代器在位置 pos
处的当前块中重复项的数量。
对于常规的非 RLE 序列,始终返回 1
。
mco_seq_rle_count_t mco_seq_rle_count(
mco_seq_iterator_h iterator,
int pos
);
is_rle
mco_seq_is_rle()
如果使用了 RLE 序列,则返回 MCO_YES
。
mco_bool mco_seq_is_rle(void);
rle_decode
mco_seq_rle_decode()
将 RLE 序列转换为一般序列
MCO_RET mco_seq_rle_decode(
mco_seq_iterator_h result,
mco_seq_iterator_h input
);
示例
以下是演示 RLE 函数的示例代码片段:
{
mco_trans_h trans;
mco_cursor_t quote_cursor;
Quote quote;
mco_seq_iterator_t rle_high_iterator, normal_high_iterator;
MCO_RET 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, "e);
Quote_high_iterator("e, &rle_high_iterator);
rc = mco_seq_rle_decode(&normal_high_iterator, &rel_high_iterator)) != MCO_S_CURSOR_END)
...
}
...
}