Documentation ¶
Overview ¶
package ic 将整型切片压缩成二进制字节切片
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Compressor ¶
type Compressor interface { // 将整型切片压缩成二进制字节切片 Marshal(ids []uint32) (ret []byte) // 将二进制字节切片反序列化为整型切片 // 反序列化后得到的整型切片,切片中整型的顺序和序列化之前保持不变 Unmarshal(b []byte) (ids []uint32) }
具体使用见 LfCompressor 和 OriginCompressor
type LfCompressor ¶ added in v0.19.0
type LfCompressor struct { Fb uint32 // 用几个字节的 bit 表示跟随的数据 ZlibExt bool // 压缩之后,是否再用 zlib 进一步压缩 // contains filtered or unexported fields }
func (*LfCompressor) Marshal ¶ added in v0.19.0
func (lfc *LfCompressor) Marshal(ids []uint32) (ret []byte)
传入的整型切片必须是从小到大有序排列
func (*LfCompressor) Unmarshal ¶ added in v0.19.0
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)
Click to show internal directories.
Click to hide internal directories.