Documentation ¶
Index ¶
- type DynamicTray
- func (t *DynamicTray[E, T]) ArrowEnd()
- func (t *DynamicTray[E, T]) ArrowStart()
- func (t *DynamicTray[E, T]) Delete(n int) error
- func (t *DynamicTray[E, T]) ExtendTapeOnLeft(elems ...T)
- func (t *DynamicTray[E, T]) ExtendTapeOnRight(elems ...T)
- func (t *DynamicTray[E, T]) Insert(elems ...T)
- func (t *DynamicTray[E, T]) Move(n int) int
- func (t *DynamicTray[E, T]) Read() (T, error)
- func (t *DynamicTray[E, T]) Write(elem T) error
- type ProceduralTray
- func (t *ProceduralTray[E, T]) ArrowEnd()
- func (t *ProceduralTray[E, T]) ArrowStart()
- func (t *ProceduralTray[E, T]) Delete(n int) error
- func (t *ProceduralTray[E, T]) ExtendTapeOnLeft(elems ...T)
- func (t *ProceduralTray[E, T]) ExtendTapeOnRight(elems ...T)
- func (t *ProceduralTray[E, T]) Insert(elems ...T)
- func (t *ProceduralTray[E, T]) Move(n int) int
- func (t *ProceduralTray[E, T]) Read() (T, error)
- func (t *ProceduralTray[E, T]) Write(elem T) error
- type SimpleTray
- func (t *SimpleTray[T]) ArrowEnd()
- func (t *SimpleTray[T]) ArrowStart()
- func (t *SimpleTray[T]) Delete(n int) error
- func (t *SimpleTray[T]) ExtendTapeOnLeft(elems ...T)
- func (t *SimpleTray[T]) ExtendTapeOnRight(elems ...T)
- func (t *SimpleTray[T]) Insert(elems ...T)
- func (t *SimpleTray[T]) Move(n int) int
- func (t *SimpleTray[T]) Read() (T, error)
- 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 DynamicTray ¶ added in v0.3.6
DynamicTray is a struct that represents a tape.
func NewDynamicTray ¶ added in v0.3.6
func NewDynamicTray[E, T any](tape []E, f func(E) *SimpleTray[T]) *DynamicTray[E, T]
NewDynamicTray creates a new DynamicTray with the given tape.
Parameters:
- tape: The tape to use.
- f: The transition function.
Returns:
- *DynamicTray: A pointer to the new DynamicTray.
func (*DynamicTray[E, T]) ArrowEnd ¶ added in v0.3.6
func (t *DynamicTray[E, T]) ArrowEnd()
ArrowEnd implements the Trayer interface.
func (*DynamicTray[E, T]) ArrowStart ¶ added in v0.3.6
func (t *DynamicTray[E, T]) ArrowStart()
ArrowStart implements the Trayer interface.
func (*DynamicTray[E, T]) Delete ¶ added in v0.3.6
func (t *DynamicTray[E, T]) Delete(n int) error
Delete implements the Trayer interface.
However, because it deletes on the dynamic tape, changes will not be saved once a new tape is generated.
func (*DynamicTray[E, T]) ExtendTapeOnLeft ¶ added in v0.3.6
func (t *DynamicTray[E, T]) ExtendTapeOnLeft(elems ...T)
ExtendTapeOnLeft implements the Trayer interface.
However, because it extends the tape on the dynamic tape, changes will not be saved once a new tape is generated.
func (*DynamicTray[E, T]) ExtendTapeOnRight ¶ added in v0.3.6
func (t *DynamicTray[E, T]) ExtendTapeOnRight(elems ...T)
ExtendTapeOnRight implements the Trayer interface.
However, because it extends the tape on the dynamic tape, changes will not be saved once a new tape is generated.
func (*DynamicTray[E, T]) Insert ¶ added in v0.3.6
func (t *DynamicTray[E, T]) Insert(elems ...T)
Insert implements the Trayer interface.
However, because it inserts on the dynamic tape, changes will not be saved once a new tape is generated.
func (*DynamicTray[E, T]) Move ¶ added in v0.3.6
func (t *DynamicTray[E, T]) Move(n int) int
Move implements the Trayer interface.
func (*DynamicTray[E, T]) Read ¶ added in v0.3.6
func (t *DynamicTray[E, T]) Read() (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[*DynamicTray] if the tape is empty.
func (*DynamicTray[E, T]) Write ¶ added in v0.3.6
func (t *DynamicTray[E, T]) Write(elem T) error
Write implements the Trayer interface.
However, because it writes on the dynamic tape, changes will not be saved once a new tape is generated.
type ProceduralTray ¶ added in v0.3.6
ProceduralTray is a struct that represents a tape.
func NewProceduralTray ¶ added in v0.3.6
func NewProceduralTray[E Trayable[T], T any](tape []E) *ProceduralTray[E, T]
NewProceduralTray creates a new ProceduralTray with the given tape.
Parameters:
- tape: The tape to use.
Returns:
- *ProceduralTray: A pointer to the new ProceduralTray.
func (*ProceduralTray[E, T]) ArrowEnd ¶ added in v0.3.6
func (t *ProceduralTray[E, T]) ArrowEnd()
ArrowEnd implements the Trayer interface.
func (*ProceduralTray[E, T]) ArrowStart ¶ added in v0.3.6
func (t *ProceduralTray[E, T]) ArrowStart()
ArrowStart implements the Trayer interface.
func (*ProceduralTray[E, T]) Delete ¶ added in v0.3.6
func (t *ProceduralTray[E, T]) Delete(n int) error
Delete implements the Trayer interface.
However, because it deletes on the dynamic tape, changes will not be saved once a new tape is generated.
func (*ProceduralTray[E, T]) ExtendTapeOnLeft ¶ added in v0.3.6
func (t *ProceduralTray[E, T]) ExtendTapeOnLeft(elems ...T)
ExtendTapeOnLeft implements the Trayer interface.
However, because it extends the tape on the dynamic tape, changes will not be saved once a new tape is generated.
func (*ProceduralTray[E, T]) ExtendTapeOnRight ¶ added in v0.3.6
func (t *ProceduralTray[E, T]) ExtendTapeOnRight(elems ...T)
ExtendTapeOnRight implements the Trayer interface.
However, because it extends the tape on the dynamic tape, changes will not be saved once a new tape is generated.
func (*ProceduralTray[E, T]) Insert ¶ added in v0.3.6
func (t *ProceduralTray[E, T]) Insert(elems ...T)
Insert implements the Trayer interface.
However, because it inserts on the dynamic tape, changes will not be saved once a new tape is generated.
func (*ProceduralTray[E, T]) Move ¶ added in v0.3.6
func (t *ProceduralTray[E, T]) Move(n int) int
Move implements the Trayer interface.
func (*ProceduralTray[E, T]) Read ¶ added in v0.3.6
func (t *ProceduralTray[E, T]) Read() (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[*ProceduralTray] if the tape is empty.
func (*ProceduralTray[E, T]) Write ¶ added in v0.3.6
func (t *ProceduralTray[E, T]) Write(elem T) error
Write implements the Trayer interface.
However, because it writes on the dynamic tape, changes will not be saved once a new tape is generated.
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 (t *SimpleTray[T]) Delete(n int) error
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[*GeneralTray]: If the tape is empty.
- *ers.ErrInvalidParameter: If n is less than 0.
func (*SimpleTray[T]) ExtendTapeOnLeft ¶ added in v0.3.6
func (t *SimpleTray[T]) ExtendTapeOnLeft(elems ...T)
ExtendTapeOnLeft extends the tape on the left with the given elements.
Parameters:
- elems: The elements to add.
func (*SimpleTray[T]) ExtendTapeOnRight ¶ added in v0.3.6
func (t *SimpleTray[T]) ExtendTapeOnRight(elems ...T)
ExtendTapeOnRight extends the tape on the right with the given elements.
Parameters:
- elems: The elements to add.
func (*SimpleTray[T]) Insert ¶ added in v0.3.6
func (t *SimpleTray[T]) Insert(elems ...T)
Insert inserts the given elements to the tape at the arrow position.
Parameters:
- elems: The elements to insert.
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 reads the element at the arrow position.
Returns:
- T: The element at the arrow position.
- error: An error of type *ers.Empty[*SimpleTray] if the tape is empty.
func (*SimpleTray[T]) Write ¶ added in v0.3.6
func (t *SimpleTray[T]) Write(elem T) error
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[*SimpleTray] if the tape is empty.
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 { // 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 // Insert inserts the given elements to the tape at the arrow position. // // Parameters: // - elems: The elements to insert. Insert(elems ...T) // 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() }
Trayer is an interface that represents any type of Tray.