Documentation
¶
Index ¶
- Variables
- func NewBlockRefSliceSubBlockCtor(refs *[]*block.BlockRef, bcs *block.Cursor, blockCtor func(idx int) block.Ctor) block.SubBlockCtor
- type BlockCtor
- type BlockRefSlice
- func (d *BlockRefSlice) AppendBlockRef(nent *block.BlockRef) *block.Cursor
- func (d *BlockRefSlice) ApplyBlockRef(id uint32, ptr *block.BlockRef) error
- func (d *BlockRefSlice) BlockPreWriteHook() error
- func (d *BlockRefSlice) FollowBlockRefAsCursor(idx int) (*block.Cursor, *block.BlockRef, error)
- func (d *BlockRefSlice) GetBlockRefAtIndex(i int) *block.BlockRef
- func (d *BlockRefSlice) GetBlockRefCtor(id uint32) block.Ctor
- func (d *BlockRefSlice) GetBlockRefs() (map[uint32]*block.BlockRef, error)
- func (d *BlockRefSlice) GetRefs() []*block.BlockRef
- func (d *BlockRefSlice) IsNil() bool
- func (d *BlockRefSlice) Len() int
- func (d *BlockRefSlice) Less(i, j int) bool
- func (d *BlockRefSlice) RemoveBlockRefs(rmRefs []*block.BlockRef) (bool, error)
- func (d *BlockRefSlice) SearchBlockRefs(ref *block.BlockRef) (idx int, match bool)
- func (d *BlockRefSlice) SetBlockCursorAtIndex(idx int, bcs *block.Cursor) error
- func (d *BlockRefSlice) SortBlockRefs()
- func (d *BlockRefSlice) Swap(i, j int)
Constants ¶
This section is empty.
Variables ¶
var ErrOutOfBounds = errors.New("ref out of bounds")
ErrOutOfBounds indicates a ref was out of bounds.
Functions ¶
Types ¶
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 ¶
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.