woot

package
v0.0.0-...-d21d2d6 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// SiteID is the global unique variable
	// used to identify the WOOT node site
	SiteID = 0

	// LocalClock is a local clock incremented whenever
	// an insert operation takes place to
	// uniquely identify each WCharacter
	LocalClock = 0
)
View Source
var (
	// WCharacterStart is a special WCharacter placed at the start
	// of the WString to denote the start of the WCharacter Sequence
	WCharacterStart = WCharacter{ID: "start", Visible: false, Alphabet: "", WCPrevious: "", WCNext: "end"}

	// WCharacterEnd is a special WCharacter placed at the end
	// of the WString to denote the end of the WCharacter Sequence
	WCharacterEnd = WCharacter{ID: "end", Visible: false, Alphabet: "", WCPrevious: "start", WCNext: ""}
)
View Source
var (
	// ErrPositionOutOfBounds is the error message sent
	// when the position out of bounds
	ErrPositionOutOfBounds = errors.New("position out of bounds")

	// ErrEmptyWCharacter is the error message sent
	// when an empty wcharacter is ID provided
	ErrEmptyWCharacter = errors.New("empty wcharacter ID provided")

	// ErrBoundsNotPresent is the error message sent
	// when subsequence bound(s) are not present
	ErrBoundsNotPresent = errors.New("subsequence bound(s) not present")
)

Functions

func Value

func Value(wstring WString) string

Value is the representation of all the visible characters in the WString

Types

type WCharacter

type WCharacter struct {
	ID         string // Identifier of the character
	Visible    bool   // Is the character visible
	Alphabet   string // Alphabetical value of the effect character
	WCPrevious string // Identifier of the previous WCharacter
	WCNext     string // Identifier of the next WCharacter
}

WCharacter is a struct used to store information about a character in our text

func IthVisible

func IthVisible(wstring WString, position int) WCharacter

IthVisible returns the ith visible WCharacter in the WString

type WString

type WString struct {
	Sequence []WCharacter // Ordered sequence of WCharacters
}

WString is used to define our text sequence It is a collection of WCharacters and Is used to save the state of the text sequence

func Initialize

func Initialize() WString

Initialize returns a WString initialized with WCharacterStart & WCharacterEnd

func (*WString) Contains

func (wstring *WString) Contains(wcharacterID string) bool

Contains returns a boolean if the given WCharacter is present in the WString

func (*WString) ElementAt

func (wstring *WString) ElementAt(position int) (WCharacter, error)

ElementAt returns the WCharacter present in the given position in the WString Sequence

func (*WString) Find

func (wstring *WString) Find(ID string) WCharacter

Find returns the WCharacter present in the WString Sequence for the given WCharacter ID

func (*WString) GenerateDelete

func (wstring *WString) GenerateDelete(position int) *WString

GenerateDelete generates the WCharacter to be marked for deletion in the WString Sequence at the given position

func (*WString) GenerateInsert

func (wstring *WString) GenerateInsert(position int, alphabet string) (*WString, error)

GenerateInsert generates a WCharacter for a given alphabet into the WString Sequence at the given position

func (*WString) IntegrateDelete

func (wstring *WString) IntegrateDelete(wcharacter WCharacter) *WString

IntegrateDelete finds out the position of the given WCharacter in the WString Sequence and marks it for deletion by setting the visible flag for it to false

func (*WString) IntegrateInsert

func (wstring *WString) IntegrateInsert(wcharacter, WCharacterPrevious, WCharacterNext WCharacter) (*WString, error)

IntegrateInsert inserts the given WCharacter into the WString Sequence based off of the previous & next WCharacter

func (*WString) Length

func (wstring *WString) Length() int

Length returns the length of the WString Sequence

func (*WString) LocalInsert

func (wstring *WString) LocalInsert(wcharacter WCharacter, position int) (*WString, error)

LocalInsert inserts the given WCharacter into the WString Sequence at the given position and shifts the remaining elements to accommodate the new WCharacter

func (*WString) Position

func (wstring *WString) Position(wcharacterID string) int

Position returns the position of the given WCharacter in the WString Sequence as a natural number

func (*WString) Subseq

func (wstring *WString) Subseq(wcharacterStart, wcharacterEnd WCharacter) ([]WCharacter, error)

Subseq return the part of the WString Sequence between wcharacterStart & wcharacterEnd

Jump to

Keyboard shortcuts

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