aakselrod / bstream

A Bit Stream helper in Golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BStream: A Bit Stream helper in Golang

GitHub license GoDoc Build Status

Install

go get github.com/kkdai/bstream

Usage

	//New a bit stream writer with default 5 byte
	b := NewBStreamWriter(5)
	
	//Write 0xa0a0 into bstream
	b.WriteBits(0xa0a0, 16)
	
	//Read 4 bit out
	result, err := b.ReadBits(4)
	if err != nil {
		log.Printf("result:%x", result)
		//result:a
	}

Inspired

Benchmark

BenchmarkWriteBits-4	100000000	        15.3 ns/op
BenchmarkReadBits-4 	50000000	        26.5 ns/op

Project52

It is one of my project 52.

License

This package is licensed under MIT license. See LICENSE for details.

About

A Bit Stream helper in Golang


Languages

Language:Go 100.0%