Documentation ¶
Index ¶
- func NewSimpleTrayWithHistory[T any](tape []T) *ud.History[*SimpleTray[T]]
- type ArrowEndCmd
- type ArrowStartCmd
- type DeleteCmd
- type ExtendLeftCmd
- type ExtendRightCmd
- type MoveCmd
- type SimpleTray
- func (t *SimpleTray[T]) ArrowEnd()
- func (t *SimpleTray[T]) ArrowStart()
- func (t *SimpleTray[T]) Copy() uc.Copier
- func (st *SimpleTray[T]) Delete(n int) int
- func (t *SimpleTray[T]) ExtendTapeOnLeft(elems ...T)
- func (t *SimpleTray[T]) ExtendTapeOnRight(elems ...T)
- func (t *SimpleTray[T]) GetLeftDistance() int
- func (t *SimpleTray[T]) GetRightDistance() int
- func (t *SimpleTray[T]) Move(n int) int
- func (t *SimpleTray[T]) Read() (T, error)
- func (t *SimpleTray[T]) ReadMany(n int) []T
- func (t *SimpleTray[T]) Write(elem T) error
- type Trayable
- type Trayer
- type WriteCmd
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSimpleTrayWithHistory ¶ added in v0.3.35
func NewSimpleTrayWithHistory[T any](tape []T) *ud.History[*SimpleTray[T]]
NewSimpleTrayWithHistory creates a new SimpleTray with the given tape and history.
Parameters:
- tape: The tape to use.
Returns:
- *Debugging.History: A pointer to the new SimpleTray.
Types ¶
type ArrowEndCmd ¶ added in v0.3.35
type ArrowEndCmd[T any] struct { // contains filtered or unexported fields }
ArrowEndCmd is a command that moves the arrow to the end of the tape.
func NewArrowEndCmd ¶ added in v0.3.35
func NewArrowEndCmd[T any]() *ArrowEndCmd[T]
NewArrowEndCmd creates a new ArrowEndCmd.
Returns:
- *ArrowEndCmd: A pointer to the new ArrowEndCmd.
func (*ArrowEndCmd[T]) Copy ¶ added in v0.3.35
func (aec *ArrowEndCmd[T]) Copy() uc.Copier
Copy implements the Debugging.Commander interface.
func (*ArrowEndCmd[T]) Execute ¶ added in v0.3.35
func (aec *ArrowEndCmd[T]) Execute(data *SimpleTray[T]) error
Execute implements the Debugging.Commander interface.
Never errors.
func (*ArrowEndCmd[T]) Undo ¶ added in v0.3.35
func (aec *ArrowEndCmd[T]) Undo(data *SimpleTray[T]) error
Undo implements the Debugging.Commander interface.
Never errors.
type ArrowStartCmd ¶ added in v0.3.35
type ArrowStartCmd[T any] struct { // contains filtered or unexported fields }
ArrowStartCmd is a command that moves the arrow to the start of the tape.
func NewArrowStartCmd ¶ added in v0.3.35
func NewArrowStartCmd[T any]() *ArrowStartCmd[T]
NewArrowStartCmd creates a new ArrowStartCmd.
Returns:
- *ArrowStartCmd: A pointer to the new ArrowStartCmd.
func (*ArrowStartCmd[T]) Copy ¶ added in v0.3.35
func (asc *ArrowStartCmd[T]) Copy() uc.Copier
Copy implements the Debugging.Commander interface.
func (*ArrowStartCmd[T]) Execute ¶ added in v0.3.35
func (asc *ArrowStartCmd[T]) Execute(data *SimpleTray[T]) error
Execute implements the Debugging.Commander interface.
Never errors.
func (*ArrowStartCmd[T]) Undo ¶ added in v0.3.35
func (asc *ArrowStartCmd[T]) Undo(data *SimpleTray[T]) error
Undo implements the Debugging.Commander interface.
Never errors.
type DeleteCmd ¶ added in v0.3.35
type DeleteCmd[T any] struct { // contains filtered or unexported fields }
DeleteCmd is a command that deletes an element from the tape.
func NewDeleteCmd ¶ added in v0.3.35
NewDeleteCmd creates a new DeleteCmd.
Parameters:
- n: The number of elements to delete.
Returns:
- *DeleteCmd: A pointer to the new DeleteCmd.
func (*DeleteCmd[T]) Execute ¶ added in v0.3.35
func (dc *DeleteCmd[T]) Execute(data *SimpleTray[T]) error
Execute implements the Debugging.Commander interface.
Never errors.
func (*DeleteCmd[T]) GetExcess ¶ added in v0.3.35
GetExcess returns the number of elements that have been deleted beyond the end of the tape.
Call this after the command has been executed.
Returns:
- int: The number of elements that have been deleted beyond the end of the tape.
func (*DeleteCmd[T]) Undo ¶ added in v0.3.35
func (dc *DeleteCmd[T]) Undo(data *SimpleTray[T]) error
Undo implements the Debugging.Commander interface.
Never errors.
type ExtendLeftCmd ¶ added in v0.3.35
type ExtendLeftCmd[T any] struct { // contains filtered or unexported fields }
ExtendLeftCmd is a command that extends the tape on the left.
func NewExtendLeftCmd ¶ added in v0.3.35
func NewExtendLeftCmd[T any](elems ...T) *ExtendLeftCmd[T]
NewExtendLeftCmd creates a new ExtendLeftCmd.
Parameters:
- elems: The elements to extend the tape with.
Returns:
- *ExtendLeftCmd: A pointer to the new ExtendLeftCmd.
func (*ExtendLeftCmd[T]) Copy ¶ added in v0.3.35
func (elc *ExtendLeftCmd[T]) Copy() uc.Copier
Copy implements the Debugging.Commander interface.
func (*ExtendLeftCmd[T]) Execute ¶ added in v0.3.35
func (elc *ExtendLeftCmd[T]) Execute(data *SimpleTray[T]) error
Execute implements the Debugging.Commander interface.
Never errors.
func (*ExtendLeftCmd[T]) Undo ¶ added in v0.3.35
func (elc *ExtendLeftCmd[T]) Undo(data *SimpleTray[T]) error
Undo implements the Debugging.Commander interface.
Never errors.
type ExtendRightCmd ¶ added in v0.3.35
type ExtendRightCmd[T any] struct { // contains filtered or unexported fields }
ExtendRightCmd is a command that extends the tape on the right.
func NewExtendRightCmd ¶ added in v0.3.35
func NewExtendRightCmd[T any](elems ...T) *ExtendRightCmd[T]
NewExtendRightCmd creates a new ExtendRightCmd.
Parameters:
- elems: The elements to extend the tape with.
Returns:
- *ExtendRightCmd: A pointer to the new ExtendRightCmd.
func (*ExtendRightCmd[T]) Copy ¶ added in v0.3.35
func (erc *ExtendRightCmd[T]) Copy() uc.Copier
Copy implements the Debugging.Commander interface.
func (*ExtendRightCmd[T]) Execute ¶ added in v0.3.35
func (erc *ExtendRightCmd[T]) Execute(data *SimpleTray[T]) error
Execute implements the Debugging.Commander interface.
Never errors.
func (*ExtendRightCmd[T]) Undo ¶ added in v0.3.35
func (erc *ExtendRightCmd[T]) Undo(data *SimpleTray[T]) error
Undo implements the Debugging.Commander interface.
Never errors.
type MoveCmd ¶ added in v0.3.35
type MoveCmd[T any] struct { // contains filtered or unexported fields }
MoveCmd is a command that moves the arrow on the tape.
func NewMoveCmd ¶ added in v0.3.35
NewMoveCmd creates a new MoveCmd.
Parameters:
- n: The number of positions to move the arrow.
Returns:
- *MoveCmd: A pointer to the new MoveCmd.
func (*MoveCmd[T]) Execute ¶ added in v0.3.35
func (mc *MoveCmd[T]) Execute(data *SimpleTray[T]) error
Execute implements the Debugging.Commander interface.
Never errors.
func (*MoveCmd[T]) GetExcess ¶ added in v0.3.35
GetExcess returns the number of positions that the arrow has moved beyond the end of the tape.
Call this after the command has been executed.
Returns:
- int: The number of positions that the arrow has moved beyond the end of the tape.
func (*MoveCmd[T]) Undo ¶ added in v0.3.35
func (mc *MoveCmd[T]) Undo(data *SimpleTray[T]) error
Undo implements the Debugging.Commander interface.
Never errors.
type SimpleTray ¶ added in v0.3.6
type SimpleTray[T any] struct { // contains filtered or unexported fields }
SimpleTray is a struct that represents a tape.
func NewSimpleTray ¶ added in v0.3.6
func NewSimpleTray[T any](tape []T) *SimpleTray[T]
NewSimpleTray creates a new GeneralTray with the given tape.
Parameters:
- tape: The tape to use.
Returns:
- *GeneralTray: A pointer to the new GeneralTray.
func (*SimpleTray[T]) ArrowEnd ¶ added in v0.3.6
func (t *SimpleTray[T]) ArrowEnd()
ArrowEnd moves the arrow to the end of the tape.
func (*SimpleTray[T]) ArrowStart ¶ added in v0.3.6
func (t *SimpleTray[T]) ArrowStart()
ArrowStart moves the arrow to the start of the tape.
func (*SimpleTray[T]) Copy ¶ added in v0.3.25
func (t *SimpleTray[T]) Copy() uc.Copier
Copy implements the Trayer interface.
func (*SimpleTray[T]) Delete ¶ added in v0.3.6
func (st *SimpleTray[T]) Delete(n int) int
Delete implements the Trayer interface.
func (*SimpleTray[T]) ExtendTapeOnLeft ¶ added in v0.3.6
func (t *SimpleTray[T]) ExtendTapeOnLeft(elems ...T)
ExtendTapeOnLeft implements the Trayer interface.
func (*SimpleTray[T]) ExtendTapeOnRight ¶ added in v0.3.6
func (t *SimpleTray[T]) ExtendTapeOnRight(elems ...T)
ExtendTapeOnRight implements the Trayer interface.
func (*SimpleTray[T]) GetLeftDistance ¶ added in v0.3.24
func (t *SimpleTray[T]) GetLeftDistance() int
GetLeftDistance implements the Trayer interface.
func (*SimpleTray[T]) GetRightDistance ¶ added in v0.3.24
func (t *SimpleTray[T]) GetRightDistance() int
GetRightDistance implements the Trayer interface.
func (*SimpleTray[T]) Move ¶ added in v0.3.6
func (t *SimpleTray[T]) Move(n int) int
Move implements the Trayer interface.
func (*SimpleTray[T]) Read ¶ added in v0.3.6
func (t *SimpleTray[T]) Read() (T, error)
Read implements the Trayer interface.
func (*SimpleTray[T]) ReadMany ¶ added in v0.3.24
func (t *SimpleTray[T]) ReadMany(n int) []T
ReadMany implements the Trayer interface.
func (*SimpleTray[T]) Write ¶ added in v0.3.6
func (t *SimpleTray[T]) Write(elem T) error
Write implements the Trayer interface.
type Trayable ¶ added in v0.3.6
type Trayable[T any] interface { // ToTray converts the Trayable to a Tray. // // Returns: // - Trayer[T]: The Tray representation of the Trayable. ToTray() Trayer[T] }
Trayable is an interface that represents a type that can be converted to a Tray.
type Trayer ¶ added in v0.3.6
type Trayer[T any] interface { // GetLeftDistance returns the distance from the arrow to the left end of the tape. // // Returns: // - int: The distance from the arrow to the left end of the tape. GetLeftDistance() int // GetRightDistance returns the distance from the arrow to the right end of the tape. // // Returns: // - int: The distance from the arrow to the right end of the tape. GetRightDistance() int // Move moves the arrow by n positions. // // Parameters: // - n: The number of positions to move the arrow. // // Returns: // - int: The number of positions the arrow's movement was limited by. // // Behaviors: // - Negative n: Move the arrow to the left by n positions. // - Positive n: Move the arrow to the right by n positions. // - 0: Do not move the arrow. Move(n int) int // Write writes the given element to the tape at the arrow position. // // Parameters: // - elem: The element to write. // // Returns: // - error: An error of type *ers.Empty[*GeneralTray] if the tape is empty. Write(elem T) error // Read reads the element at the arrow position. // // Returns: // - T: The element at the arrow position. // - error: An error of type *ers.Empty[*GeneralTray] if the tape is empty. Read() (T, error) // Delete deletes n elements to the right of the arrow position. // // Parameters: // - n: The number of elements to delete. // // Returns: // - int: The number of elements that were not deleted. Delete(n int) int // ExtendTapeOnLeft extends the tape on the left with the given elements. // // Parameters: // - elems: The elements to add. ExtendTapeOnLeft(elems ...T) // ExtendTapeOnRight extends the tape on the right with the given elements. // // Parameters: // - elems: The elements to add. ExtendTapeOnRight(elems ...T) // ArrowStart moves the arrow to the start of the tape. ArrowStart() // ArrowEnd moves the arrow to the end of the tape. ArrowEnd() uc.Copier }
Trayer is an interface that represents any type of Tray.
type WriteCmd ¶ added in v0.3.35
type WriteCmd[T any] struct { // contains filtered or unexported fields }
WriteCmd is a command that writes an element to the tape.
func NewWriteCmd ¶ added in v0.3.35
NewWriteCmd creates a new WriteCmd.
Parameters:
- elem: The element to write.
Returns:
- *WriteCmd: A pointer to the new WriteCmd.
func (*WriteCmd[T]) Execute ¶ added in v0.3.35
func (wc *WriteCmd[T]) Execute(data *SimpleTray[T]) error
Execute implements the Debugging.Commander interface.
func (*WriteCmd[T]) Undo ¶ added in v0.3.35
func (wc *WriteCmd[T]) Undo(data *SimpleTray[T]) error
Undo implements the Debugging.Commander interface.