runes

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type String

type String []rune

func (String) Append

func (xs String) Append(add ...rune) StringDelta

func (String) Apply

func (xs String) Apply(ops []StringOp) String

func (String) CanApply

func (xs String) CanApply(ops []StringOp) bool

func (String) Delete

func (xs String) Delete(i, num int) StringDelta

func (String) DeleteElements

func (xs String) DeleteElements(del ...rune) StringDelta

func (String) Insert

func (xs String) Insert(i int, add ...rune) StringDelta

func (String) PrefixMatch

func (xs String) PrefixMatch(ys []rune) int

PrefixMatch returns the number of elements at the beginning of xs that match the elements at the beginning of ys.

func (String) Retain

func (xs String) Retain(r int) StringDelta

func (String) String

func (xs String) String() string

type StringDelta

type StringDelta []StringOp

func StringDiff

func StringDiff(a, b []rune) StringDelta

StringDiff produces a set of operations that can be applied to xs to produce a slice that would match slice b.

func (StringDelta) Delete

func (x StringDelta) Delete(d int) StringDelta

func (StringDelta) Insert

func (x StringDelta) Insert(add ...rune) StringDelta

func (StringDelta) Rebase

func (x StringDelta) Rebase(base StringDelta) (StringDelta, error)

func (StringDelta) Retain

func (x StringDelta) Retain(r int) StringDelta

type StringOp

type StringOp interface {
	// Leaves returns how many elements of a slice of length n would remain
	// to be transformed by additional ops after applying this op. Returns
	// a negative number if and only if this op cannot be coherently
	// applied to a slice of length n.
	Leaves(n int) int
	// Len returns the number of elements inserted, retained, or deleted by
	// this op.
	Len() int
	// Skip returns an equivalent op that assumes its intent is already carried
	// out for the first n elements. May panic if n > Len().
	Skip(n int) StringOp
	// Rebase transforms op into a rebased op r (or nil), a subsequent op for
	// rebasing xn (or nil), and a subsequent base bn (or nil).
	Rebase(base StringOp) (r StringOp, xn StringOp, bn StringOp)
	// Compact expands this op to include o if possible, returning true if
	// successful.
	Compact(o StringOp) (StringOp, bool)
	Apply(String) (include String, remainder String)
	String() string
}

type StringOpDelete

type StringOpDelete int

func (StringOpDelete) Apply

func (x StringOpDelete) Apply(xs String) (String, String)

func (StringOpDelete) Compact

func (x StringOpDelete) Compact(op StringOp) (StringOp, bool)

func (StringOpDelete) Leaves

func (x StringOpDelete) Leaves(in int) int

func (StringOpDelete) Len

func (x StringOpDelete) Len() int

func (StringOpDelete) Rebase

func (x StringOpDelete) Rebase(base StringOp) (StringOp, StringOp, StringOp)

func (StringOpDelete) Skip

func (x StringOpDelete) Skip(n int) StringOp

func (StringOpDelete) String

func (x StringOpDelete) String() string

type StringOpInsert

type StringOpInsert []rune

func (StringOpInsert) Apply

func (x StringOpInsert) Apply(xs String) (String, String)

func (StringOpInsert) Compact

func (x StringOpInsert) Compact(op StringOp) (StringOp, bool)

func (StringOpInsert) Leaves

func (x StringOpInsert) Leaves(in int) int

func (StringOpInsert) Len

func (x StringOpInsert) Len() int

func (StringOpInsert) Rebase

func (x StringOpInsert) Rebase(base StringOp) (StringOp, StringOp, StringOp)

func (StringOpInsert) Skip

func (x StringOpInsert) Skip(n int) StringOp

func (StringOpInsert) String

func (x StringOpInsert) String() string

type StringOpRetain

type StringOpRetain int

func (StringOpRetain) Apply

func (x StringOpRetain) Apply(xs String) (String, String)

func (StringOpRetain) Compact

func (x StringOpRetain) Compact(op StringOp) (StringOp, bool)

func (StringOpRetain) Leaves

func (x StringOpRetain) Leaves(in int) int

func (StringOpRetain) Len

func (x StringOpRetain) Len() int

func (StringOpRetain) Rebase

func (x StringOpRetain) Rebase(base StringOp) (StringOp, StringOp, StringOp)

func (StringOpRetain) Skip

func (x StringOpRetain) Skip(n int) StringOp

func (StringOpRetain) String

func (x StringOpRetain) String() string

Jump to

Keyboard shortcuts

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