refslice

package
v0.51.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOutOfBounds = errors.New("ref out of bounds")

ErrOutOfBounds indicates a ref was out of bounds.

Functions

func NewBlockRefSliceSubBlockCtor

func NewBlockRefSliceSubBlockCtor(
	refs *[]*block.BlockRef,
	bcs *block.Cursor,
	blockCtor func(idx int) block.Ctor,
) block.SubBlockCtor

NewBlockRefSliceSubBlockCtor returns the sub-block constructor.

Types

type BlockCtor

type BlockCtor func()

BlockCtor should construct a block at an index.

type BlockRefSlice

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

BlockRefSlice implements block ref slice functions.

func NewBlockRefSlice

func NewBlockRefSlice(
	refs *[]*block.BlockRef,
	bcs *block.Cursor,
	blockCtor func(idx int) block.Ctor,
) *BlockRefSlice

NewBlockRefSlice builds a new BlockRefSlice from a slice pointer. bcs can be nil, should be a cursor located at the slice. blockCtor can be nil, should construct a block at index. on a object containing []*block.BlockRef, use FollowSubBlock(refID)

func (*BlockRefSlice) AppendBlockRef

func (d *BlockRefSlice) AppendBlockRef(nent *block.BlockRef) *block.Cursor

AppendBlockRef appends a entry to the ref slice.

func (*BlockRefSlice) ApplyBlockRef

func (d *BlockRefSlice) 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 (*BlockRefSlice) BlockPreWriteHook

func (d *BlockRefSlice) BlockPreWriteHook() error

BlockPreWriteHook is called when writing the block.

func (*BlockRefSlice) FollowBlockRefAsCursor

func (d *BlockRefSlice) FollowBlockRefAsCursor(idx int) (*block.Cursor, *block.BlockRef, error)

FollowBlockRefAsCursor follows a index to its node reference. bcs must be set on the ref slice may return ErrOutOfBounds

func (*BlockRefSlice) GetBlockRefAtIndex

func (d *BlockRefSlice) GetBlockRefAtIndex(i int) *block.BlockRef

GetBlockRefAtIndex returns a ref at an index.

func (*BlockRefSlice) GetBlockRefCtor

func (d *BlockRefSlice) 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 (*BlockRefSlice) GetBlockRefs

func (d *BlockRefSlice) 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 (*BlockRefSlice) GetRefs

func (d *BlockRefSlice) GetRefs() []*block.BlockRef

GetRefs returns the refs slice.

func (*BlockRefSlice) IsNil

func (d *BlockRefSlice) IsNil() bool

IsNil checks if the object is nil.

func (*BlockRefSlice) Len

func (d *BlockRefSlice) Len() int

Len is the number of elements in the collection.

func (*BlockRefSlice) Less

func (d *BlockRefSlice) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j. does not do bounds checks

func (*BlockRefSlice) RemoveBlockRefs

func (d *BlockRefSlice) RemoveBlockRefs(rmRefs []*block.BlockRef) (bool, error)

RemoveBlockRefs removes one or more directory entries. refs must be sorted. returns if any were removed. after removing all entries be sure to call SortBlockRefs.

func (*BlockRefSlice) SearchBlockRefs

func (d *BlockRefSlice) SearchBlockRefs(ref *block.BlockRef) (idx int, match bool)

SearchBlockRefs searches a ref slice for a ref. If not found returns the index it should be inserted.

func (*BlockRefSlice) SetBlockCursorAtIndex

func (d *BlockRefSlice) SetBlockCursorAtIndex(idx int, bcs *block.Cursor) error

SetBlockCursorAtIndex sets the reference to a cursor at the index. The index must already exist, and bcs be set, or returns ErrOutOfBounds

func (*BlockRefSlice) SortBlockRefs

func (d *BlockRefSlice) SortBlockRefs()

SortBlockRefs sorts a ref slice.

func (*BlockRefSlice) Swap

func (d *BlockRefSlice) Swap(i, j int)

Swap swaps the elements with indexes i and j. If bcs is set on ref slice, also swaps reference ids.

Jump to

Keyboard shortcuts

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