libfor是一个ANSIC库,是参考框架(FrameOfReference)整数压缩的快速标量实现。
libfor可以压缩顺序或者乱序的数列,另外,此库可以在压缩数据上直接执行操作:
选择:在指定索引处返回一个值;
线性搜索:对于未排序数列,或者短排序数列
下界搜索:对排序数列的二进制搜索
示例代码:
#define LEN 100uint32_t in[LEN] = {0};uint8_t out[512];// Fill |in| with numbers of your choicefor (int i = 0; i < LEN; i++) in[i] = i;// Now compress; can also use for_compress_sorted() if the numbers// are sorted. This is slightly faster.uint32_t size = for_compress_unsorted(&in[0], &out[0], LEN);printf("compressing %u integers (%u bytes) into %u bytes\n", LEN, LEN * 4, size);// Decompress againuint32_t decompressed[LEN];for_uncompress(&out[0], &decompressed[0], LEN);
评论