Help us shape the future of Go! Take the 2026 Go Developer Survey

immutablevector

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package immutablevector owns compact immutable slices behind authenticated roots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authority

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

Authority authenticates roots created for one owner.

func NewAuthority

func NewAuthority[T any]() *Authority[T]

NewAuthority creates an isolated root authority.

func (*Authority[T]) Own

func (a *Authority[T]) Own(values []T) (Root[T], error)

Own clones values and returns their authenticated immutable root.

type Root

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

Root is a copyable authenticated immutable vector.

func (Root[T]) At

func (r Root[T]) At(authority *Authority[T], index int) (T, error)

At returns one value without exposing the backing slice.

func (Root[T]) Len

func (r Root[T]) Len(authority *Authority[T]) (int, error)

Len returns the immutable vector length.

func (Root[T]) Range

func (r Root[T]) Range(authority *Authority[T], visit func(T) bool) error

Range visits values in order until visit returns false.

func (Root[T]) SameRoot

func (r Root[T]) SameRoot(authority *Authority[T], other Root[T]) (bool, error)

SameRoot compares exact authenticated storage identity in O(1).

func (Root[T]) ValidateOwnership

func (r Root[T]) ValidateOwnership(authority *Authority[T]) error

ValidateOwnership verifies a root in O(1).

func (Root[T]) Values

func (r Root[T]) Values(authority *Authority[T]) ([]T, error)

Values returns a detached copy of every value.

Jump to

Keyboard shortcuts

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