ic

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

package ic 将整型切片压缩成二进制字节切片

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sort

func Sort(ids []uint32)

Types

type Compressor

type Compressor interface {
	// 将整型切片压缩成二进制字节切片
	Marshal(ids []uint32) (ret []byte)
	// 将二进制字节切片反序列化为整型切片
	// 反序列化后得到的整型切片,切片中整型的顺序和序列化之前保持不变
	Unmarshal(b []byte) (ids []uint32)
}

具体使用见 LFCompressor 和 OriginCompressor

type LFCompressor

type LFCompressor struct {
	FB      uint32 // 用几个字节的 bit 表示跟随的数据
	ZlibExt bool   // 压缩之后,是否再用 zlib 进一步压缩
	// contains filtered or unexported fields
}

func (*LFCompressor) Marshal

func (lfc *LFCompressor) Marshal(ids []uint32) (ret []byte)

传入的整型切片必须是从小到大有序排列

func (*LFCompressor) Unmarshal

func (lfc *LFCompressor) Unmarshal(b []byte) (ids []uint32)

type OriginCompressor

type OriginCompressor struct {
	ZlibExt bool // 压缩之后,是否再用 zlib 进一步压缩
}

func (*OriginCompressor) Marshal

func (oc *OriginCompressor) Marshal(ids []uint32) (ret []byte)

并不强制要求整型切片有序

func (*OriginCompressor) Unmarshal

func (oc *OriginCompressor) Unmarshal(b []byte) (ids []uint32)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL