cr

package
v0.1.34 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ServerCr

type ServerCr[Data any, Meta comparable] interface {
	Len() int

	// Read flattens this state for use by end users.
	Read(a, b int) *ServerCrState[Data, Meta]

	// LastSeq returns the last node ID.
	// This may be a deleted ID and not normally visible.
	LastSeq() int

	// HighSeq returns the high node ID.
	// Will be zero at start.
	HighSeq() int

	// PositionFor returns the position for the given ID.
	PositionFor(id int) int

	// PerformAppend inserts data after the prior node.
	// Use HighSeq to return its new ID.
	PerformAppend(after int, data []Data, meta Meta) (deleted, ok bool)

	// PerformDelete marks the given range as deleted.
	// Both arguments point directly to nodes, so it is valid for both values to be equal (and deletion of "one" will occur).
	// Returns the newly deleted range, which may be less than given (deleting within already deleted).
	// If there's no newly deleted range, the range is [0,0], but this can still be 'ok'.
	PerformDelete(from, until int) (a, b int, ok bool)
}

func New

func New[Data any, Meta comparable]() ServerCr[Data, Meta]

New creates a new ServerCr. TODO: it can't really be _used_ yet

type ServerCrState

type ServerCrState[Data, Meta any] struct {
	Data []Data // underlying data in run stuck together
	Seq  []int  // pairs of [length,seqDelta]
	Meta []Meta // meta of data, always half of Seq
}

Jump to

Keyboard shortcuts

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