container

package
v0.0.0-...-17cad6e Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bitmap

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

Bitmap is a growable, concurrent-safe compressed bitmap.

func NewBitmap

func NewBitmap(bitCount uint64) *Bitmap

NewBitmap returns a bitmap with a logical capacity for bitCount bits. All bits are initially clear. Storage remains sparse until bits are set.

func (*Bitmap) And

func (b *Bitmap) And(other *Bitmap)

And retains only bits also present in other.

func (*Bitmap) AndNot

func (b *Bitmap) AndNot(other *Bitmap)

AndNot clears every bit present in other.

func (*Bitmap) Clear

func (b *Bitmap) Clear(bit uint64) bool

Clear clears bit and reports whether its value changed.

func (*Bitmap) Clone

func (b *Bitmap) Clone() *Bitmap

Clone returns an independent copy of b.

func (*Bitmap) Contains

func (b *Bitmap) Contains(bit uint64) bool

Contains reports whether bit is set.

func (*Bitmap) Count

func (b *Bitmap) Count() uint64

Count returns the number of set bits.

func (*Bitmap) Or

func (b *Bitmap) Or(other *Bitmap)

Or sets every bit present in other.

func (*Bitmap) Range

func (b *Bitmap) Range(yield func(bit uint64) bool)

Range calls yield for set bits in ascending order and stops when yield returns false. The callback runs against a snapshot and may mutate b.

func (*Bitmap) Set

func (b *Bitmap) Set(bit uint64) bool

Set sets bit and reports whether its value changed.

func (*Bitmap) Snapshot

func (b *Bitmap) Snapshot() []uint64

Snapshot returns a dense copy of the bitmap words in little bit order. Its memory use is proportional to the highest bit ever set or NewBitmap's logical capacity; sparse callers should prefer Clone or Range.

func (*Bitmap) SnapshotWithin

func (b *Bitmap) SnapshotWithin(bitCount uint64) ([]uint64, bool)

SnapshotWithin returns a dense snapshot bounded to bitCount bits. It reports false without allocating the dense snapshot when a set bit is outside the requested domain.

type Heap

type Heap[T any] struct {
	// contains filtered or unexported fields
}

Heap is a binary heap ordered by less. If less(a, b) is true, a is nearer the root than b. Heap is not safe for concurrent mutation.

func NewHeap

func NewHeap[T any](less func(a, b T) bool) *Heap[T]

NewHeap constructs an empty heap. It panics when less is nil.

func NewHeapWithCapacity

func NewHeapWithCapacity[T any](capacity int, less func(a, b T) bool) *Heap[T]

NewHeapWithCapacity constructs an empty heap with storage reserved for at least capacity values. It panics when capacity is negative or less is nil.

func (*Heap[T]) Len

func (h *Heap[T]) Len() int

Len returns the number of values in h.

func (*Heap[T]) Peek

func (h *Heap[T]) Peek() (T, bool)

Peek returns the root without removing it.

func (*Heap[T]) Pop

func (h *Heap[T]) Pop() (T, bool)

Pop removes and returns the root.

func (*Heap[T]) Push

func (h *Heap[T]) Push(value T)

Push inserts value into h.

func (*Heap[T]) Replace

func (h *Heap[T]) Replace(value T) (T, bool)

Replace replaces and returns the root. If h is empty, it inserts value and reports false because no prior root existed.

func (*Heap[T]) Values

func (h *Heap[T]) Values() []T

Values returns a copy of the heap's internal level order.

Jump to

Keyboard shortcuts

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