微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

libfor 整数压缩 C 语言库

程序名称:libfor

授权协议: Apache

操作系统: 跨平台

开发语言: C/C++

libfor 介绍

libfor 是一个 ANSI C 库,是参考框架(Frame Of Reference)整数压缩的快速标量实现。

libfor 可以压缩顺序或者乱序的数列,另外,此库可以在压缩数据上直接执行操作:

  • 选择:在指定索引处返回一个值;

  • 线性搜索:对于未排序数列,或者短排序数列

  • 下界搜索:对排序数列的二进制搜索

示例代码

#define LEN 100
uint32_t in[LEN] = {0};
uint8_t out[512];

// Fill |in| with numbers of your choice
for (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 again
uint32_t decompressed[LEN];
for_uncompress(&out[0], &decompressed[0], LEN);

libfor 官网

https://github.com/cruppstahl/for#libfor---fast-c-library-for-frame-of-reference-integer-compression

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐