namedrefslice

package
v0.51.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NamedBlockRef

type NamedBlockRef interface {
	// GetName returns the name of the ref.
	GetName() string
	// GetRef returns the reference.
	GetRef() *block.BlockRef
	// SetRef sets the reference.
	SetRef(*block.BlockRef)
}

NamedBlockRef is a named block reference.

type NamedBlockRefSet

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

NamedBlockRefSet contains a set of block ref objects with name.

The list is sorted / keyed by name, unique.

func NewNamedBlockRefSet

func NewNamedBlockRefSet(sl NamedBlockRefSetContainer, bcs *block.Cursor) *NamedBlockRefSet

NewNamedBlockRefSet constructs a new NamedBlockRefSet from a slice pointer.

also contains an optional block cursor

func (*NamedBlockRefSet) ApplyBlockRef

func (r *NamedBlockRefSet) ApplyBlockRef(id uint32, ptr *block.BlockRef) error

ApplyBlockRef applies a ref change with a field id. The reference may be nil if the child block is nil.

func (*NamedBlockRefSet) BlockPreWriteHook

func (r *NamedBlockRefSet) BlockPreWriteHook() error

BlockPreWriteHook is called when writing the block.

func (*NamedBlockRefSet) GetBlockRefCtor

func (r *NamedBlockRefSet) GetBlockRefCtor(id uint32) block.Ctor

GetBlockRefCtor returns the constructor for the block at the ref id. Return nil to indicate invalid ref ID or unknown.

func (*NamedBlockRefSet) GetBlockRefs

func (r *NamedBlockRefSet) GetBlockRefs() (map[uint32]*block.BlockRef, error)

GetBlockRefs returns all block references by ID. May return nil, and values may also be nil. Note: this does not include pending references (in a cursor)

func (*NamedBlockRefSet) GetCursor

func (r *NamedBlockRefSet) GetCursor() *block.Cursor

GetCursor returns the sub-block cursor located at r, if set.

func (*NamedBlockRefSet) IsNil

func (r *NamedBlockRefSet) IsNil() bool

IsNil checks if the object is nil.

func (*NamedBlockRefSet) Len

func (r *NamedBlockRefSet) Len() int

Len is the number of elements in the collection.

func (*NamedBlockRefSet) Less

func (r *NamedBlockRefSet) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (*NamedBlockRefSet) LookupByName

func (r *NamedBlockRefSet) LookupByName(name string) (NamedBlockRef, *block.Cursor, bool)

LookupByName looks up a database by name.

Returns bcs located at root_db.ref. Returns nil, false if not found. Returns nil block cursor if bcs is not set.

func (*NamedBlockRefSet) LookupIndexByName

func (r *NamedBlockRefSet) LookupIndexByName(name string) (idx int)

LookupIndexByName looks up a database index by name.

Returns either -1 or len(sl) if not found or nil.

func (*NamedBlockRefSet) SortNamedRefs

func (r *NamedBlockRefSet) SortNamedRefs()

SortNamedRefs sorts by name.

func (*NamedBlockRefSet) Swap

func (r *NamedBlockRefSet) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type NamedBlockRefSetContainer

type NamedBlockRefSetContainer interface {
	// Get returns the value at the index.
	//
	// Return nil if out of bounds, etc.
	Get(i int) NamedBlockRef
	// Len returns the number of elements.
	Len() int
	// Set sets the value at the index.
	Set(i int, r NamedBlockRef)
	// GetBlockRefCtor returns the block constructor for the referenced block.
	GetBlockRefCtor(i int) block.Ctor
}

NamedBlockRefSetContainer is a named block reference container.

Jump to

Keyboard shortcuts

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