Documentation ¶
Index ¶
- type Tray
- func (t *Tray[T]) ArrowEnd()
- func (t *Tray[T]) ArrowStart()
- func (t *Tray[T]) Delete(n int) error
- func (t *Tray[T]) ExtendTapeOnLeft(elems ...T)
- func (t *Tray[T]) ExtendTapeOnRight(elems ...T)
- func (t *Tray[T]) Insert(elems ...T)
- func (t *Tray[T]) MoveLeft(n int) bool
- func (t *Tray[T]) MoveRight(n int) bool
- func (t *Tray[T]) Read() (T, error)
- func (t *Tray[T]) ShiftLeftOfArrow(n int)
- func (t *Tray[T]) ShiftRightOfArrow(n int)
- func (t *Tray[T]) Write(elem T) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tray ¶
type Tray[T any] struct { // contains filtered or unexported fields }
Tray is a struct that represents a tape.
func NewTray ¶
NewTray creates a new Tray with the given tape.
Parameters:
- tape: The tape to use.
Returns:
- *Tray: A pointer to the new Tray.
func (*Tray[T]) ArrowEnd ¶
func (t *Tray[T]) ArrowEnd()
ArrowEnd moves the arrow to the end of the tape.
func (*Tray[T]) ArrowStart ¶
func (t *Tray[T]) ArrowStart()
ArrowStart moves the arrow to the start of the tape.
func (*Tray[T]) Delete ¶
ReadLeft reads the element to the left of the arrow position.
Returns:
- T: The element to the left of the arrow position.
- error: An error if elements to the left of the arrow position cannot be found.
Errors:
- *ers.ErrEmpty[*Tray]: If the tape is empty.
- *ers.ErrInvalidParameter: If n is less than 0.
func (*Tray[T]) ExtendTapeOnLeft ¶
func (t *Tray[T]) ExtendTapeOnLeft(elems ...T)
ExtendTapeOnLeft extends the tape on the left with the given elements.
Parameters:
- elems: The elements to add.
func (*Tray[T]) ExtendTapeOnRight ¶
func (t *Tray[T]) ExtendTapeOnRight(elems ...T)
ExtendTapeOnRight extends the tape on the right with the given elements.
Parameters:
- elems: The elements to add.
func (*Tray[T]) Insert ¶
func (t *Tray[T]) Insert(elems ...T)
Insert inserts the given elements to the tape at the arrow position.
Parameters:
- elems: The elements to insert.
func (*Tray[T]) MoveLeft ¶
MoveLeft moves the arrow to the left by n positions.
Parameters:
- n: The number of positions to move the arrow.
Returns:
- bool: True if the number of positions is equal to n, false otherwise.
func (*Tray[T]) MoveRight ¶
MoveRight moves the arrow to the right by n positions.
Parameters:
- n: The number of positions to move the arrow.
Returns:
- bool: True if the number of positions is equal to n, false otherwise.
func (*Tray[T]) Read ¶
Read reads the element at the arrow position.
Returns:
- T: The element at the arrow position.
- error: An error of type *ers.Empty[*Tray] if the tape is empty.
func (*Tray[T]) ShiftLeftOfArrow ¶
ShiftLeftOfArrow shifts the elements on the right of the arrow to the left by n positions.
Parameters:
- n: The number of positions to shift the elements.
func (*Tray[T]) ShiftRightOfArrow ¶
ShiftRightOfArrow shifts the elements on the left of the arrow to the right by n positions.
Parameters:
- n: The number of positions to shift the elements.