Documentation ¶
Index ¶
- type SimpleTray
- func (t *SimpleTray[T]) ArrowEnd()
- func (t *SimpleTray[T]) ArrowStart()
- 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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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]) 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: // - error: An error of type *ers.ErrInvalidParameter if n is less than 0. Delete(n int) error // 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.