binary

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BitmapSize

func BitmapSize(entityCount uint32) int

BitmapSize returns the number of bytes required to hold a bitmap for the given entity count.

func Clear

func Clear(bm []byte, bit int)

Clear turns off the bit at position bit in bm.

func Has

func Has(bm []byte, bit int) bool

Has reports whether the bit at position bit in bm is set.

func PopCount

func PopCount(bm []byte) int

PopCount returns the number of set bits in bm. It processes the bitmap in 64-bit chunks, falling back to byte-wise counting for the trailing tail.

func Set

func Set(bm []byte, bit int)

Set turns on the bit at position bit in bm.

Types

type Data

type Data []byte

Data is the binary-encoded payload of a Groupings object. It stores a concatenated sequence of fixed-size bitmaps, one per grouping, in the same order as the names table in Headers.

func (*Data) AppendBitmap

func (d *Data) AppendBitmap(size int)

AppendBitmap appends a new zero-initialised bitmap of the given size.

func (*Data) Bitmap

func (d *Data) Bitmap(i, size int) []byte

Bitmap returns the sub-slice backing the i-th bitmap. Mutations on the returned slice are reflected in the underlying Data.

type Headers

type Headers []byte

Headers is the binary-encoded header block of a Groupings payload.

Layout (little-endian):

[0..4]   magic number (4 bytes)
[4..8]   entity count (uint32)
[8..12]  grouping count (uint32)
[12..]   names table: for each grouping, uint16 length + utf-8 name bytes

func NewHeaders

func NewHeaders(entityCount uint32) *Headers

NewHeaders returns a new Headers initialised with the given entity count and zero groupings.

func ParseHeaders

func ParseHeaders(raw []byte) (Headers, int, error)

ParseHeaders parses a Headers block from raw bytes and returns the parsed headers together with the number of bytes consumed.

func (*Headers) AppendName

func (h *Headers) AppendName(name string) uint32

AppendName appends a grouping name to the names table and returns its index.

func (*Headers) EntityCount

func (h *Headers) EntityCount() uint32

EntityCount returns the number of entities addressable by every grouping.

func (*Headers) GroupingCount

func (h *Headers) GroupingCount() uint32

GroupingCount returns the number of groupings.

func (*Headers) IndexOf

func (h *Headers) IndexOf(name string) int

IndexOf returns the index of the grouping with the given name, or -1.

func (*Headers) MagicNumber

func (h *Headers) MagicNumber() [4]byte

func (*Headers) Names

func (h *Headers) Names() []string

Names returns all grouping names in insertion order.

func (*Headers) SetMagicNumber

func (h *Headers) SetMagicNumber(magicNumber [4]byte)

Jump to

Keyboard shortcuts

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