Documentation
¶
Index ¶
- Variables
- func Value(wstring WString) string
- type WCharacter
- type WString
- func (wstring *WString) Contains(wcharacterID string) bool
- func (wstring *WString) ElementAt(position int) (WCharacter, error)
- func (wstring *WString) Find(ID string) WCharacter
- func (wstring *WString) GenerateDelete(position int) *WString
- func (wstring *WString) GenerateInsert(position int, alphabet string) (*WString, error)
- func (wstring *WString) IntegrateDelete(wcharacter WCharacter) *WString
- func (wstring *WString) IntegrateInsert(wcharacter, WCharacterPrevious, WCharacterNext WCharacter) (*WString, error)
- func (wstring *WString) Length() int
- func (wstring *WString) LocalInsert(wcharacter WCharacter, position int) (*WString, error)
- func (wstring *WString) Position(wcharacterID string) int
- func (wstring *WString) Subseq(wcharacterStart, wcharacterEnd WCharacter) ([]WCharacter, error)
Constants ¶
This section is empty.
Variables ¶
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 )
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: ""} )
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 ¶
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 ¶
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 ¶
GenerateDelete generates the WCharacter to be marked for deletion in the WString Sequence at the given position
func (*WString) GenerateInsert ¶
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) 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 ¶
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