tables

package
v0.0.0-...-84d6781 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SD tablesT

SD is the namespace for SD-like functions.

Functions

This section is empty.

Types

type Table

type Table[T any] struct {
	// contains filtered or unexported fields
}

Table is a boundless table. This means that any operation done to out-of-bounds cells will not cause any error.

func NewTable

func NewTable[T any](width, height int) (*Table[T], error)

NewTable creates a new Table with a width and height.

Parameters:

  • width: The width of the table.
  • height: The height of the table.

Returns:

  • *Table: The new Table.
  • error: If the table could not be created.

Errors:

  • errors.BadParameterError: If width or height is negative.

func (Table[T]) CellAt

func (t Table[T]) CellAt(x, y int) T

CellAt returns the cell at the specified position.

Parameters:

  • x: The x position of the cell.
  • y: The y position of the cell.

Returns:

  • T: The cell at the specified position. The zero value if the position is out of bounds.

func (*Table[T]) Cleanup

func (t *Table[T]) Cleanup()

Cleanup cleans up the table. Does nothing if the receiver is nil or if is already cleaned up.

func (Table[T]) Height

func (t Table[T]) Height() int

Height returns the height of the table.

Returns:

  • int: The height of the table.

func (*Table[T]) ResizeHeight

func (t *Table[T]) ResizeHeight(new_height int) error

ResizeHeight resizes the height of the table. The height is not resized if the receiver is nil or the new height is the same as the current height.

Parameters:

  • new_height: The new height of the table.

Returns:

  • error: If the table could not be resized.

Errors:

  • gers.BadParameterError: If new_height is negative.

func (*Table[T]) ResizeWidth

func (t *Table[T]) ResizeWidth(new_width int) error

ResizeWidth resizes the width of the table. The width is not resized if the receiver is nil or the new width is the same as the current width.

Parameters:

  • new_width: The new width of the table.

Returns:

  • error: If the table could not be resized.

Errors:

  • gers.BadParameterError: If new_width is negative.

func (Table[T]) Row

func (t Table[T]) Row() iter.Seq2[int, []T]

Row returns an iterator over the rows in the table.

Returns:

  • iter.Seq2[int, []T]: An iterator over the rows in the table. Never returns nil.

func (*Table[T]) SetCellAt

func (t *Table[T]) SetCellAt(cell T, x, y int)

SetCellAt sets the cell at the specified position. The cell is not set if the receiver is nil or the position is out of bounds.

Parameters:

  • cell: The cell to set.
  • x: The x position of the cell.
  • y: The y position of the cell.

func (Table[T]) Width

func (t Table[T]) Width() int

Width returns the width of the table.

Returns:

  • int: The width of the table.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL