heap

package
v0.0.0-...-32c7374 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinBlockSize = 1 << minIndex
	MaxBlockSize = 1 << maxIndex
)

Variables

View Source
var Global = New()

Functions

This section is empty.

Types

type Block

type Block struct {
	// contains filtered or unexported fields
}

func (*Block) Alloc

func (b *Block) Alloc(size int) unsafe.Pointer

Alloc returns an aligned byte slice or nil.

inlineable

func (*Block) Bytes

func (b *Block) Bytes() []byte

Bytes returns the underlying block bytes.

func (*Block) Cap

func (b *Block) Cap() int

Cap returns the block capacity in bytes.

func (*Block) Grow

func (b *Block) Grow(size int) []byte

Grow grows the buffer and allocates a byte slice.

func (*Block) Len

func (b *Block) Len() int

Len returns the number of used bytes in the block.

func (*Block) Rem

func (b *Block) Rem() int

Rem returns the remaining free space in bytes.

func (*Block) Reset

func (b *Block) Reset()

Reset resets the block.

type Heap

type Heap struct {
	// contains filtered or unexported fields
}

func New

func New() *Heap

New returns a new heap.

func (*Heap) Alloc

func (h *Heap) Alloc(size int) *Block

Alloc allocates a new block.

func (*Heap) Free

func (h *Heap) Free(b *Block)

Free frees a block.

func (*Heap) FreeMany

func (h *Heap) FreeMany(blocks ...*Block)

FreeMany frees multiple blocks.

Jump to

Keyboard shortcuts

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