table

package module
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 2 Imported by: 1

README

table

A Go package used for generating tables implemented without bounds. It also features some already generated tables.

Table of Contents

  1. Table of Contents
  2. Tool
  3. Documentation
  4. Content

Tool

Installation

To install the tool, run the following command:

go get -u github.com/PlayerR9/table/cmd
Usage

Once imported, you can use the tool to generate tables for your own types. Like so:

import _ "github.com/PlayerR9/table"

// go:generate go run table/cmd -name=Foo -type=int

This generates a table with the name "Foo" whose cells are of type "int".

The type generated will be in the same package as the tool. Make sure to read the documentation of the tool before using it.

Documentation

This command generates a table of the given type implemented as a boundless table (i.e., out-of-bounds errors are not thrown).

To use it, run the following command:

   go:generate go run table/cmd -name=<type_name> -type=<type> [ -g=<generics>] [ -o=<output_file> ]

**Flag: Name**

The "name" flag is used to specify the name of the table. As such, it must be set and,
not only does it have to be a valid Go identifier, but it also must start with an upper case letter.

**Flag: Type**

The "fields" flag is used to specify type of the table's cells. This flag must be set.

For instance, running the following command:

   go:generate table -name=Table -type=int

will generate a table with the following structure:

   type Table struct {
      table [][]int
   }

It is important to note that spaces are not allowed in any of the flags.

Also, it is possible to specify generics by following the value with the generics between square brackets;
like so: "MyType[T,C]"


**Flag: Generics**

This optional flag is used to specify the type(s) of the generics. However, this only applies if at least one
generic type is specified in the type flag. If none, then this flag is ignored.

As an edge case, if this flag is not specified but the type flag contains generics, then
all generics are set to the default value of "any".

Its argument is specified as a list of key-value pairs where each pair is separated
by a comma (",") and a slash ("/") is used to separate the key and the value. The key indicates the name of
the generic and the value indicates the type of the generic.

For instance, running the following command:

   go:generate table -name=Table -type=MyType[T] -g=T/any

will generate a table with the following fields:

   type Table[T any] struct {
      table [][]T
   }


**Flag: Output File**

This optional flag is used to specify the output file. If not specified, the output will be written to
standard output, that is, the file "<type_name>_table.go" in the root of the current directory.

Content

Here are all the pregenerated files:

Documentation

Overview

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Code generated by go:generate. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FixBoundaries

func FixBoundaries[T any](maxWidth, maxHeight int, elems [][]T, x, y *int) [][]T

FixBoundaries is a function that fixes the boundaries of a table of elements based on the maximum width and height of the table.

Parameters:

  • maxWidth: The maximum width of the table.
  • maxHeight: The maximum height of the table.
  • elems: The elements of the table.
  • x: The x-coordinate to fix the boundaries at.
  • y: The y-coordinate to fix the boundaries at.

Returns:

  • [][]T: The elements of the table with the boundaries fixed.

Behaviors:

  • If maxWidth is less than 0, it is set to 0.
  • If maxHeight is less than 0, it is set to 0.
  • If elems is empty, nil is returned.

Types

type BoolTable

type BoolTable struct {
	// contains filtered or unexported fields
}

BoolTable represents a table of cells that can be drawn to the screen.

func NewBoolTable

func NewBoolTable(width, height int) *BoolTable

NewBoolTable creates a new table of type bool with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *BoolTable: The new table. Never nil.

func (*BoolTable) Cell added in v0.1.12

func (t *BoolTable) Cell() iter.Seq[bool]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type bool.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*BoolTable) Cleanup

func (t *BoolTable) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type bool.

func (*BoolTable) GetAt

func (t *BoolTable) GetAt(x, y int) bool

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type bool.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • bool: The cell at the given coordinates.

func (*BoolTable) GetFullTable

func (t *BoolTable) GetFullTable() [][]bool

GetFullTable returns the full table as a 2D slice of elements of type bool.

Returns:

  • [][]bool: The full table.

func (*BoolTable) GetHeight

func (t *BoolTable) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*BoolTable) GetWidth

func (t *BoolTable) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*BoolTable) IsXInBounds

func (t *BoolTable) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*BoolTable) IsYInBounds

func (t *BoolTable) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*BoolTable) WriteAt

func (t *BoolTable) WriteAt(x, y int, cell bool)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*BoolTable) WriteHorizontalSequence

func (t *BoolTable) WriteHorizontalSequence(x, y *int, sequence []bool)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*BoolTable) WriteTableAt

func (t *BoolTable) WriteTableAt(table *BoolTable, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*BoolTable) WriteVerticalSequence

func (t *BoolTable) WriteVerticalSequence(x, y *int, sequence []bool)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type ByteTable

type ByteTable struct {
	// contains filtered or unexported fields
}

ByteTable represents a table of cells that can be drawn to the screen.

func NewByteTable

func NewByteTable(width, height int) *ByteTable

NewByteTable creates a new table of type byte with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *ByteTable: The new table. Never nil.

func (*ByteTable) Cell added in v0.1.12

func (t *ByteTable) Cell() iter.Seq[byte]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type byte.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*ByteTable) Cleanup

func (t *ByteTable) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type byte.

func (*ByteTable) GetAt

func (t *ByteTable) GetAt(x, y int) byte

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type byte.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • byte: The cell at the given coordinates.

func (*ByteTable) GetFullTable

func (t *ByteTable) GetFullTable() [][]byte

GetFullTable returns the full table as a 2D slice of elements of type byte.

Returns:

  • [][]byte: The full table.

func (*ByteTable) GetHeight

func (t *ByteTable) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*ByteTable) GetWidth

func (t *ByteTable) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*ByteTable) IsXInBounds

func (t *ByteTable) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*ByteTable) IsYInBounds

func (t *ByteTable) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*ByteTable) WriteAt

func (t *ByteTable) WriteAt(x, y int, cell byte)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*ByteTable) WriteHorizontalSequence

func (t *ByteTable) WriteHorizontalSequence(x, y *int, sequence []byte)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*ByteTable) WriteTableAt

func (t *ByteTable) WriteTableAt(table *ByteTable, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*ByteTable) WriteVerticalSequence

func (t *ByteTable) WriteVerticalSequence(x, y *int, sequence []byte)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type Complex128Table

type Complex128Table struct {
	// contains filtered or unexported fields
}

Complex128Table represents a table of cells that can be drawn to the screen.

func NewComplex128Table

func NewComplex128Table(width, height int) *Complex128Table

NewComplex128Table creates a new table of type complex128 with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *Complex128Table: The new table. Never nil.

func (*Complex128Table) Cell added in v0.1.12

func (t *Complex128Table) Cell() iter.Seq[complex128]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type complex128.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*Complex128Table) Cleanup

func (t *Complex128Table) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type complex128.

func (*Complex128Table) GetAt

func (t *Complex128Table) GetAt(x, y int) complex128

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type complex128.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • complex128: The cell at the given coordinates.

func (*Complex128Table) GetFullTable

func (t *Complex128Table) GetFullTable() [][]complex128

GetFullTable returns the full table as a 2D slice of elements of type complex128.

Returns:

  • [][]complex128: The full table.

func (*Complex128Table) GetHeight

func (t *Complex128Table) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*Complex128Table) GetWidth

func (t *Complex128Table) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*Complex128Table) IsXInBounds

func (t *Complex128Table) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*Complex128Table) IsYInBounds

func (t *Complex128Table) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*Complex128Table) WriteAt

func (t *Complex128Table) WriteAt(x, y int, cell complex128)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*Complex128Table) WriteHorizontalSequence

func (t *Complex128Table) WriteHorizontalSequence(x, y *int, sequence []complex128)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*Complex128Table) WriteTableAt

func (t *Complex128Table) WriteTableAt(table *Complex128Table, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*Complex128Table) WriteVerticalSequence

func (t *Complex128Table) WriteVerticalSequence(x, y *int, sequence []complex128)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type Complex64Table

type Complex64Table struct {
	// contains filtered or unexported fields
}

Complex64Table represents a table of cells that can be drawn to the screen.

func NewComplex64Table

func NewComplex64Table(width, height int) *Complex64Table

NewComplex64Table creates a new table of type complex64 with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *Complex64Table: The new table. Never nil.

func (*Complex64Table) Cell added in v0.1.12

func (t *Complex64Table) Cell() iter.Seq[complex64]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type complex64.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*Complex64Table) Cleanup

func (t *Complex64Table) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type complex64.

func (*Complex64Table) GetAt

func (t *Complex64Table) GetAt(x, y int) complex64

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type complex64.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • complex64: The cell at the given coordinates.

func (*Complex64Table) GetFullTable

func (t *Complex64Table) GetFullTable() [][]complex64

GetFullTable returns the full table as a 2D slice of elements of type complex64.

Returns:

  • [][]complex64: The full table.

func (*Complex64Table) GetHeight

func (t *Complex64Table) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*Complex64Table) GetWidth

func (t *Complex64Table) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*Complex64Table) IsXInBounds

func (t *Complex64Table) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*Complex64Table) IsYInBounds

func (t *Complex64Table) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*Complex64Table) WriteAt

func (t *Complex64Table) WriteAt(x, y int, cell complex64)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*Complex64Table) WriteHorizontalSequence

func (t *Complex64Table) WriteHorizontalSequence(x, y *int, sequence []complex64)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*Complex64Table) WriteTableAt

func (t *Complex64Table) WriteTableAt(table *Complex64Table, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*Complex64Table) WriteVerticalSequence

func (t *Complex64Table) WriteVerticalSequence(x, y *int, sequence []complex64)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type ErrorTable

type ErrorTable struct {
	// contains filtered or unexported fields
}

ErrorTable represents a table of cells that can be drawn to the screen.

func NewErrorTable

func NewErrorTable(width, height int) *ErrorTable

NewErrorTable creates a new table of type error with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *ErrorTable: The new table. Never nil.

func (*ErrorTable) Cell added in v0.1.12

func (t *ErrorTable) Cell() iter.Seq[error]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type error.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*ErrorTable) Cleanup

func (t *ErrorTable) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type error.

func (*ErrorTable) GetAt

func (t *ErrorTable) GetAt(x, y int) error

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type error.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • error: The cell at the given coordinates.

func (*ErrorTable) GetFullTable

func (t *ErrorTable) GetFullTable() [][]error

GetFullTable returns the full table as a 2D slice of elements of type error.

Returns:

  • [][]error: The full table.

func (*ErrorTable) GetHeight

func (t *ErrorTable) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*ErrorTable) GetWidth

func (t *ErrorTable) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*ErrorTable) IsXInBounds

func (t *ErrorTable) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*ErrorTable) IsYInBounds

func (t *ErrorTable) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*ErrorTable) WriteAt

func (t *ErrorTable) WriteAt(x, y int, cell error)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*ErrorTable) WriteHorizontalSequence

func (t *ErrorTable) WriteHorizontalSequence(x, y *int, sequence []error)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*ErrorTable) WriteTableAt

func (t *ErrorTable) WriteTableAt(table *ErrorTable, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*ErrorTable) WriteVerticalSequence

func (t *ErrorTable) WriteVerticalSequence(x, y *int, sequence []error)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type Float32Table

type Float32Table struct {
	// contains filtered or unexported fields
}

Float32Table represents a table of cells that can be drawn to the screen.

func NewFloat32Table

func NewFloat32Table(width, height int) *Float32Table

NewFloat32Table creates a new table of type float32 with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *Float32Table: The new table. Never nil.

func (*Float32Table) Cell added in v0.1.12

func (t *Float32Table) Cell() iter.Seq[float32]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type float32.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*Float32Table) Cleanup

func (t *Float32Table) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type float32.

func (*Float32Table) GetAt

func (t *Float32Table) GetAt(x, y int) float32

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type float32.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • float32: The cell at the given coordinates.

func (*Float32Table) GetFullTable

func (t *Float32Table) GetFullTable() [][]float32

GetFullTable returns the full table as a 2D slice of elements of type float32.

Returns:

  • [][]float32: The full table.

func (*Float32Table) GetHeight

func (t *Float32Table) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*Float32Table) GetWidth

func (t *Float32Table) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*Float32Table) IsXInBounds

func (t *Float32Table) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*Float32Table) IsYInBounds

func (t *Float32Table) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*Float32Table) WriteAt

func (t *Float32Table) WriteAt(x, y int, cell float32)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*Float32Table) WriteHorizontalSequence

func (t *Float32Table) WriteHorizontalSequence(x, y *int, sequence []float32)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*Float32Table) WriteTableAt

func (t *Float32Table) WriteTableAt(table *Float32Table, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*Float32Table) WriteVerticalSequence

func (t *Float32Table) WriteVerticalSequence(x, y *int, sequence []float32)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type Float64Table

type Float64Table struct {
	// contains filtered or unexported fields
}

Float64Table represents a table of cells that can be drawn to the screen.

func NewFloat64Table

func NewFloat64Table(width, height int) *Float64Table

NewFloat64Table creates a new table of type float64 with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *Float64Table: The new table. Never nil.

func (*Float64Table) Cell added in v0.1.12

func (t *Float64Table) Cell() iter.Seq[float64]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type float64.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*Float64Table) Cleanup

func (t *Float64Table) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type float64.

func (*Float64Table) GetAt

func (t *Float64Table) GetAt(x, y int) float64

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type float64.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • float64: The cell at the given coordinates.

func (*Float64Table) GetFullTable

func (t *Float64Table) GetFullTable() [][]float64

GetFullTable returns the full table as a 2D slice of elements of type float64.

Returns:

  • [][]float64: The full table.

func (*Float64Table) GetHeight

func (t *Float64Table) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*Float64Table) GetWidth

func (t *Float64Table) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*Float64Table) IsXInBounds

func (t *Float64Table) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*Float64Table) IsYInBounds

func (t *Float64Table) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*Float64Table) WriteAt

func (t *Float64Table) WriteAt(x, y int, cell float64)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*Float64Table) WriteHorizontalSequence

func (t *Float64Table) WriteHorizontalSequence(x, y *int, sequence []float64)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*Float64Table) WriteTableAt

func (t *Float64Table) WriteTableAt(table *Float64Table, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*Float64Table) WriteVerticalSequence

func (t *Float64Table) WriteVerticalSequence(x, y *int, sequence []float64)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type Int16Table

type Int16Table struct {
	// contains filtered or unexported fields
}

Int16Table represents a table of cells that can be drawn to the screen.

func NewInt16Table

func NewInt16Table(width, height int) *Int16Table

NewInt16Table creates a new table of type int16 with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *Int16Table: The new table. Never nil.

func (*Int16Table) Cell added in v0.1.12

func (t *Int16Table) Cell() iter.Seq[int16]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type int16.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*Int16Table) Cleanup

func (t *Int16Table) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type int16.

func (*Int16Table) GetAt

func (t *Int16Table) GetAt(x, y int) int16

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type int16.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • int16: The cell at the given coordinates.

func (*Int16Table) GetFullTable

func (t *Int16Table) GetFullTable() [][]int16

GetFullTable returns the full table as a 2D slice of elements of type int16.

Returns:

  • [][]int16: The full table.

func (*Int16Table) GetHeight

func (t *Int16Table) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*Int16Table) GetWidth

func (t *Int16Table) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*Int16Table) IsXInBounds

func (t *Int16Table) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*Int16Table) IsYInBounds

func (t *Int16Table) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*Int16Table) WriteAt

func (t *Int16Table) WriteAt(x, y int, cell int16)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*Int16Table) WriteHorizontalSequence

func (t *Int16Table) WriteHorizontalSequence(x, y *int, sequence []int16)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*Int16Table) WriteTableAt

func (t *Int16Table) WriteTableAt(table *Int16Table, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*Int16Table) WriteVerticalSequence

func (t *Int16Table) WriteVerticalSequence(x, y *int, sequence []int16)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type Int32Table

type Int32Table struct {
	// contains filtered or unexported fields
}

Int32Table represents a table of cells that can be drawn to the screen.

func NewInt32Table

func NewInt32Table(width, height int) *Int32Table

NewInt32Table creates a new table of type int32 with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *Int32Table: The new table. Never nil.

func (*Int32Table) Cell added in v0.1.12

func (t *Int32Table) Cell() iter.Seq[int32]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type int32.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*Int32Table) Cleanup

func (t *Int32Table) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type int32.

func (*Int32Table) GetAt

func (t *Int32Table) GetAt(x, y int) int32

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type int32.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • int32: The cell at the given coordinates.

func (*Int32Table) GetFullTable

func (t *Int32Table) GetFullTable() [][]int32

GetFullTable returns the full table as a 2D slice of elements of type int32.

Returns:

  • [][]int32: The full table.

func (*Int32Table) GetHeight

func (t *Int32Table) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*Int32Table) GetWidth

func (t *Int32Table) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*Int32Table) IsXInBounds

func (t *Int32Table) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*Int32Table) IsYInBounds

func (t *Int32Table) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*Int32Table) WriteAt

func (t *Int32Table) WriteAt(x, y int, cell int32)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*Int32Table) WriteHorizontalSequence

func (t *Int32Table) WriteHorizontalSequence(x, y *int, sequence []int32)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*Int32Table) WriteTableAt

func (t *Int32Table) WriteTableAt(table *Int32Table, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*Int32Table) WriteVerticalSequence

func (t *Int32Table) WriteVerticalSequence(x, y *int, sequence []int32)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type Int64Table

type Int64Table struct {
	// contains filtered or unexported fields
}

Int64Table represents a table of cells that can be drawn to the screen.

func NewInt64Table

func NewInt64Table(width, height int) *Int64Table

NewInt64Table creates a new table of type int64 with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *Int64Table: The new table. Never nil.

func (*Int64Table) Cell added in v0.1.12

func (t *Int64Table) Cell() iter.Seq[int64]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type int64.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*Int64Table) Cleanup

func (t *Int64Table) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type int64.

func (*Int64Table) GetAt

func (t *Int64Table) GetAt(x, y int) int64

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type int64.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • int64: The cell at the given coordinates.

func (*Int64Table) GetFullTable

func (t *Int64Table) GetFullTable() [][]int64

GetFullTable returns the full table as a 2D slice of elements of type int64.

Returns:

  • [][]int64: The full table.

func (*Int64Table) GetHeight

func (t *Int64Table) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*Int64Table) GetWidth

func (t *Int64Table) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*Int64Table) IsXInBounds

func (t *Int64Table) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*Int64Table) IsYInBounds

func (t *Int64Table) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*Int64Table) WriteAt

func (t *Int64Table) WriteAt(x, y int, cell int64)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*Int64Table) WriteHorizontalSequence

func (t *Int64Table) WriteHorizontalSequence(x, y *int, sequence []int64)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*Int64Table) WriteTableAt

func (t *Int64Table) WriteTableAt(table *Int64Table, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*Int64Table) WriteVerticalSequence

func (t *Int64Table) WriteVerticalSequence(x, y *int, sequence []int64)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type Int8Table

type Int8Table struct {
	// contains filtered or unexported fields
}

Int8Table represents a table of cells that can be drawn to the screen.

func NewInt8Table

func NewInt8Table(width, height int) *Int8Table

NewInt8Table creates a new table of type int8 with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *Int8Table: The new table. Never nil.

func (*Int8Table) Cell added in v0.1.12

func (t *Int8Table) Cell() iter.Seq[int8]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type int8.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*Int8Table) Cleanup

func (t *Int8Table) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type int8.

func (*Int8Table) GetAt

func (t *Int8Table) GetAt(x, y int) int8

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type int8.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • int8: The cell at the given coordinates.

func (*Int8Table) GetFullTable

func (t *Int8Table) GetFullTable() [][]int8

GetFullTable returns the full table as a 2D slice of elements of type int8.

Returns:

  • [][]int8: The full table.

func (*Int8Table) GetHeight

func (t *Int8Table) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*Int8Table) GetWidth

func (t *Int8Table) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*Int8Table) IsXInBounds

func (t *Int8Table) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*Int8Table) IsYInBounds

func (t *Int8Table) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*Int8Table) WriteAt

func (t *Int8Table) WriteAt(x, y int, cell int8)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*Int8Table) WriteHorizontalSequence

func (t *Int8Table) WriteHorizontalSequence(x, y *int, sequence []int8)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*Int8Table) WriteTableAt

func (t *Int8Table) WriteTableAt(table *Int8Table, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*Int8Table) WriteVerticalSequence

func (t *Int8Table) WriteVerticalSequence(x, y *int, sequence []int8)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type IntTable

type IntTable struct {
	// contains filtered or unexported fields
}

IntTable represents a table of cells that can be drawn to the screen.

func NewIntTable

func NewIntTable(width, height int) *IntTable

NewIntTable creates a new table of type int with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *IntTable: The new table. Never nil.

func (*IntTable) Cell added in v0.1.12

func (t *IntTable) Cell() iter.Seq[int]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type int.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*IntTable) Cleanup

func (t *IntTable) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type int.

func (*IntTable) GetAt

func (t *IntTable) GetAt(x, y int) int

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type int.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • int: The cell at the given coordinates.

func (*IntTable) GetFullTable

func (t *IntTable) GetFullTable() [][]int

GetFullTable returns the full table as a 2D slice of elements of type int.

Returns:

  • [][]int: The full table.

func (*IntTable) GetHeight

func (t *IntTable) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*IntTable) GetWidth

func (t *IntTable) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*IntTable) IsXInBounds

func (t *IntTable) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*IntTable) IsYInBounds

func (t *IntTable) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*IntTable) WriteAt

func (t *IntTable) WriteAt(x, y int, cell int)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*IntTable) WriteHorizontalSequence

func (t *IntTable) WriteHorizontalSequence(x, y *int, sequence []int)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*IntTable) WriteTableAt

func (t *IntTable) WriteTableAt(table *IntTable, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*IntTable) WriteVerticalSequence

func (t *IntTable) WriteVerticalSequence(x, y *int, sequence []int)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type RuneTable

type RuneTable struct {
	// contains filtered or unexported fields
}

RuneTable represents a table of cells that can be drawn to the screen.

func NewRuneTable

func NewRuneTable(width, height int) *RuneTable

NewRuneTable creates a new table of type rune with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *RuneTable: The new table. Never nil.

func (*RuneTable) Cell added in v0.1.12

func (t *RuneTable) Cell() iter.Seq[rune]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type rune.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*RuneTable) Cleanup

func (t *RuneTable) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type rune.

func (*RuneTable) GetAt

func (t *RuneTable) GetAt(x, y int) rune

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type rune.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • rune: The cell at the given coordinates.

func (*RuneTable) GetFullTable

func (t *RuneTable) GetFullTable() [][]rune

GetFullTable returns the full table as a 2D slice of elements of type rune.

Returns:

  • [][]rune: The full table.

func (*RuneTable) GetHeight

func (t *RuneTable) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*RuneTable) GetWidth

func (t *RuneTable) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*RuneTable) IsXInBounds

func (t *RuneTable) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*RuneTable) IsYInBounds

func (t *RuneTable) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*RuneTable) WriteAt

func (t *RuneTable) WriteAt(x, y int, cell rune)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*RuneTable) WriteHorizontalSequence

func (t *RuneTable) WriteHorizontalSequence(x, y *int, sequence []rune)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*RuneTable) WriteTableAt

func (t *RuneTable) WriteTableAt(table *RuneTable, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*RuneTable) WriteVerticalSequence

func (t *RuneTable) WriteVerticalSequence(x, y *int, sequence []rune)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type StringTable

type StringTable struct {
	// contains filtered or unexported fields
}

StringTable represents a table of cells that can be drawn to the screen.

func NewStringTable

func NewStringTable(width, height int) *StringTable

NewStringTable creates a new table of type string with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *StringTable: The new table. Never nil.

func (*StringTable) Cell added in v0.1.12

func (t *StringTable) Cell() iter.Seq[string]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type string.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*StringTable) Cleanup

func (t *StringTable) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type string.

func (*StringTable) GetAt

func (t *StringTable) GetAt(x, y int) string

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type string.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • string: The cell at the given coordinates.

func (*StringTable) GetFullTable

func (t *StringTable) GetFullTable() [][]string

GetFullTable returns the full table as a 2D slice of elements of type string.

Returns:

  • [][]string: The full table.

func (*StringTable) GetHeight

func (t *StringTable) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*StringTable) GetWidth

func (t *StringTable) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*StringTable) IsXInBounds

func (t *StringTable) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*StringTable) IsYInBounds

func (t *StringTable) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*StringTable) WriteAt

func (t *StringTable) WriteAt(x, y int, cell string)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*StringTable) WriteHorizontalSequence

func (t *StringTable) WriteHorizontalSequence(x, y *int, sequence []string)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*StringTable) WriteTableAt

func (t *StringTable) WriteTableAt(table *StringTable, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*StringTable) WriteVerticalSequence

func (t *StringTable) WriteVerticalSequence(x, y *int, sequence []string)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type Table

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

Table[T any] represents a table of cells that can be drawn to the screen.

func NewTable

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

NewTable creates a new table of type T with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *Table[T]: The new table. Never nil.

func (*Table[T]) Cell added in v0.1.12

func (t *Table[T]) Cell() iter.Seq[T]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type T.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*Table[T]) Cleanup

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

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type T.

func (*Table[T]) GetAt

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

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type T.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • T: The cell at the given coordinates.

func (*Table[T]) GetFullTable

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

GetFullTable returns the full table as a 2D slice of elements of type T.

Returns:

  • [][]T: The full table.

func (*Table[T]) GetHeight

func (t *Table[T]) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*Table[T]) GetWidth

func (t *Table[T]) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*Table[T]) IsXInBounds

func (t *Table[T]) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*Table[T]) IsYInBounds

func (t *Table[T]) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*Table[T]) WriteAt

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

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*Table[T]) WriteHorizontalSequence

func (t *Table[T]) WriteHorizontalSequence(x, y *int, sequence []T)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*Table[T]) WriteTableAt

func (t *Table[T]) WriteTableAt(table *Table[T], x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*Table[T]) WriteVerticalSequence

func (t *Table[T]) WriteVerticalSequence(x, y *int, sequence []T)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type Uint16Table

type Uint16Table struct {
	// contains filtered or unexported fields
}

Uint16Table represents a table of cells that can be drawn to the screen.

func NewUint16Table

func NewUint16Table(width, height int) *Uint16Table

NewUint16Table creates a new table of type uint16 with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *Uint16Table: The new table. Never nil.

func (*Uint16Table) Cell added in v0.1.12

func (t *Uint16Table) Cell() iter.Seq[uint16]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type uint16.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*Uint16Table) Cleanup

func (t *Uint16Table) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type uint16.

func (*Uint16Table) GetAt

func (t *Uint16Table) GetAt(x, y int) uint16

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type uint16.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • uint16: The cell at the given coordinates.

func (*Uint16Table) GetFullTable

func (t *Uint16Table) GetFullTable() [][]uint16

GetFullTable returns the full table as a 2D slice of elements of type uint16.

Returns:

  • [][]uint16: The full table.

func (*Uint16Table) GetHeight

func (t *Uint16Table) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*Uint16Table) GetWidth

func (t *Uint16Table) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*Uint16Table) IsXInBounds

func (t *Uint16Table) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*Uint16Table) IsYInBounds

func (t *Uint16Table) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*Uint16Table) WriteAt

func (t *Uint16Table) WriteAt(x, y int, cell uint16)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*Uint16Table) WriteHorizontalSequence

func (t *Uint16Table) WriteHorizontalSequence(x, y *int, sequence []uint16)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*Uint16Table) WriteTableAt

func (t *Uint16Table) WriteTableAt(table *Uint16Table, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*Uint16Table) WriteVerticalSequence

func (t *Uint16Table) WriteVerticalSequence(x, y *int, sequence []uint16)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type Uint32Table

type Uint32Table struct {
	// contains filtered or unexported fields
}

Uint32Table represents a table of cells that can be drawn to the screen.

func NewUint32Table

func NewUint32Table(width, height int) *Uint32Table

NewUint32Table creates a new table of type uint32 with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *Uint32Table: The new table. Never nil.

func (*Uint32Table) Cell added in v0.1.12

func (t *Uint32Table) Cell() iter.Seq[uint32]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type uint32.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*Uint32Table) Cleanup

func (t *Uint32Table) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type uint32.

func (*Uint32Table) GetAt

func (t *Uint32Table) GetAt(x, y int) uint32

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type uint32.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • uint32: The cell at the given coordinates.

func (*Uint32Table) GetFullTable

func (t *Uint32Table) GetFullTable() [][]uint32

GetFullTable returns the full table as a 2D slice of elements of type uint32.

Returns:

  • [][]uint32: The full table.

func (*Uint32Table) GetHeight

func (t *Uint32Table) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*Uint32Table) GetWidth

func (t *Uint32Table) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*Uint32Table) IsXInBounds

func (t *Uint32Table) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*Uint32Table) IsYInBounds

func (t *Uint32Table) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*Uint32Table) WriteAt

func (t *Uint32Table) WriteAt(x, y int, cell uint32)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*Uint32Table) WriteHorizontalSequence

func (t *Uint32Table) WriteHorizontalSequence(x, y *int, sequence []uint32)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*Uint32Table) WriteTableAt

func (t *Uint32Table) WriteTableAt(table *Uint32Table, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*Uint32Table) WriteVerticalSequence

func (t *Uint32Table) WriteVerticalSequence(x, y *int, sequence []uint32)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type Uint64Table

type Uint64Table struct {
	// contains filtered or unexported fields
}

Uint64Table represents a table of cells that can be drawn to the screen.

func NewUint64Table

func NewUint64Table(width, height int) *Uint64Table

NewUint64Table creates a new table of type uint64 with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *Uint64Table: The new table. Never nil.

func (*Uint64Table) Cell added in v0.1.12

func (t *Uint64Table) Cell() iter.Seq[uint64]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type uint64.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*Uint64Table) Cleanup

func (t *Uint64Table) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type uint64.

func (*Uint64Table) GetAt

func (t *Uint64Table) GetAt(x, y int) uint64

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type uint64.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • uint64: The cell at the given coordinates.

func (*Uint64Table) GetFullTable

func (t *Uint64Table) GetFullTable() [][]uint64

GetFullTable returns the full table as a 2D slice of elements of type uint64.

Returns:

  • [][]uint64: The full table.

func (*Uint64Table) GetHeight

func (t *Uint64Table) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*Uint64Table) GetWidth

func (t *Uint64Table) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*Uint64Table) IsXInBounds

func (t *Uint64Table) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*Uint64Table) IsYInBounds

func (t *Uint64Table) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*Uint64Table) WriteAt

func (t *Uint64Table) WriteAt(x, y int, cell uint64)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*Uint64Table) WriteHorizontalSequence

func (t *Uint64Table) WriteHorizontalSequence(x, y *int, sequence []uint64)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*Uint64Table) WriteTableAt

func (t *Uint64Table) WriteTableAt(table *Uint64Table, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*Uint64Table) WriteVerticalSequence

func (t *Uint64Table) WriteVerticalSequence(x, y *int, sequence []uint64)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type Uint8Table

type Uint8Table struct {
	// contains filtered or unexported fields
}

Uint8Table represents a table of cells that can be drawn to the screen.

func NewUint8Table

func NewUint8Table(width, height int) *Uint8Table

NewUint8Table creates a new table of type uint8 with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *Uint8Table: The new table. Never nil.

func (*Uint8Table) Cell added in v0.1.12

func (t *Uint8Table) Cell() iter.Seq[uint8]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type uint8.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*Uint8Table) Cleanup

func (t *Uint8Table) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type uint8.

func (*Uint8Table) GetAt

func (t *Uint8Table) GetAt(x, y int) uint8

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type uint8.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • uint8: The cell at the given coordinates.

func (*Uint8Table) GetFullTable

func (t *Uint8Table) GetFullTable() [][]uint8

GetFullTable returns the full table as a 2D slice of elements of type uint8.

Returns:

  • [][]uint8: The full table.

func (*Uint8Table) GetHeight

func (t *Uint8Table) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*Uint8Table) GetWidth

func (t *Uint8Table) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*Uint8Table) IsXInBounds

func (t *Uint8Table) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*Uint8Table) IsYInBounds

func (t *Uint8Table) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*Uint8Table) WriteAt

func (t *Uint8Table) WriteAt(x, y int, cell uint8)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*Uint8Table) WriteHorizontalSequence

func (t *Uint8Table) WriteHorizontalSequence(x, y *int, sequence []uint8)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*Uint8Table) WriteTableAt

func (t *Uint8Table) WriteTableAt(table *Uint8Table, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*Uint8Table) WriteVerticalSequence

func (t *Uint8Table) WriteVerticalSequence(x, y *int, sequence []uint8)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type UintTable

type UintTable struct {
	// contains filtered or unexported fields
}

UintTable represents a table of cells that can be drawn to the screen.

func NewUintTable

func NewUintTable(width, height int) *UintTable

NewUintTable creates a new table of type uint with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *UintTable: The new table. Never nil.

func (*UintTable) Cell added in v0.1.12

func (t *UintTable) Cell() iter.Seq[uint]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type uint.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*UintTable) Cleanup

func (t *UintTable) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type uint.

func (*UintTable) GetAt

func (t *UintTable) GetAt(x, y int) uint

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type uint.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • uint: The cell at the given coordinates.

func (*UintTable) GetFullTable

func (t *UintTable) GetFullTable() [][]uint

GetFullTable returns the full table as a 2D slice of elements of type uint.

Returns:

  • [][]uint: The full table.

func (*UintTable) GetHeight

func (t *UintTable) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*UintTable) GetWidth

func (t *UintTable) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*UintTable) IsXInBounds

func (t *UintTable) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*UintTable) IsYInBounds

func (t *UintTable) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*UintTable) WriteAt

func (t *UintTable) WriteAt(x, y int, cell uint)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*UintTable) WriteHorizontalSequence

func (t *UintTable) WriteHorizontalSequence(x, y *int, sequence []uint)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*UintTable) WriteTableAt

func (t *UintTable) WriteTableAt(table *UintTable, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*UintTable) WriteVerticalSequence

func (t *UintTable) WriteVerticalSequence(x, y *int, sequence []uint)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

type UintptrTable

type UintptrTable struct {
	// contains filtered or unexported fields
}

UintptrTable represents a table of cells that can be drawn to the screen.

func NewUintptrTable

func NewUintptrTable(width, height int) *UintptrTable

NewUintptrTable creates a new table of type uintptr with the given width and height. Negative parameters are treated as absolute values.

Parameters:

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

Returns:

  • *UintptrTable: The new table. Never nil.

func (*UintptrTable) Cell added in v0.1.12

func (t *UintptrTable) Cell() iter.Seq[uintptr]

Cell returns an iterator that is a pull-model iterator that scans the table row by row as it was an array of elements of type uintptr.

Example:

[ a b c ]
[ d e f ]

Cell() -> [ a ] -> [ b ] -> [ c ] -> [ d ] -> [ e ] -> [ f ]

func (*UintptrTable) Cleanup

func (t *UintptrTable) Cleanup()

Cleanup is a method that cleans up the table.

It sets all cells in the table to the zero value of type uintptr.

func (*UintptrTable) GetAt

func (t *UintptrTable) GetAt(x, y int) uintptr

GetAt returns the cell at the given coordinates in the table. However, out-of-bounds coordinates return the zero value of type uintptr.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.

Returns:

  • uintptr: The cell at the given coordinates.

func (*UintptrTable) GetFullTable

func (t *UintptrTable) GetFullTable() [][]uintptr

GetFullTable returns the full table as a 2D slice of elements of type uintptr.

Returns:

  • [][]uintptr: The full table.

func (*UintptrTable) GetHeight

func (t *UintptrTable) GetHeight() int

GetHeight returns the height of the table.

Returns:

  • int: The height of the table. Never negative.

func (*UintptrTable) GetWidth

func (t *UintptrTable) GetWidth() int

GetWidth returns the width of the table.

Returns:

  • int: The width of the table. Never negative.

func (*UintptrTable) IsXInBounds

func (t *UintptrTable) IsXInBounds(x int) error

IsXInBounds checks if the given x-coordinate is within the bounds of the table.

Parameters:

  • x: The x-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the x-coordinate is out of bounds.

func (*UintptrTable) IsYInBounds

func (t *UintptrTable) IsYInBounds(y int) error

IsYInBounds checks if the given y-coordinate is within the bounds of the table.

Parameters:

  • y: The y-coordinate to check.

Returns:

  • error: An error of type *ints.ErrOutOfBounds if the y-coordinate is out of bounds.

func (*UintptrTable) WriteAt

func (t *UintptrTable) WriteAt(x, y int, cell uintptr)

WriteAt writes a cell to the table at the given coordinates. However, out-of-bounds coordinates do nothing.

Parameters:

  • x: The x-coordinate of the cell.
  • y: The y-coordinate of the cell.
  • cell: The cell to write to the table.

func (*UintptrTable) WriteHorizontalSequence

func (t *UintptrTable) WriteHorizontalSequence(x, y *int, sequence []uintptr)

WriteHorizontalSequence is the equivalent of WriteVerticalSequence but for horizontal sequences.

See WriteVerticalSequence for more information.

Parameters:

  • x: The x-coordinate of the starting cell.
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

func (*UintptrTable) WriteTableAt

func (t *UintptrTable) WriteTableAt(table *UintptrTable, x, y *int)

WriteTableAt is a convenience function that copies the values from the given table to the table starting at the given coordinates in a more efficient way than using any other methods.

While it acts in the same way as both WriteVerticalSequence and WriteHorizontalSequence combined, it is more efficient than calling those two functions separately.

See WriteVerticalSequence for more information.

Parameters:

  • table: The table to write to the table.
  • x: The x-coordinate to write the table at.
  • y: The y-coordinate to write the table at.

If the table is nil, x or y are nil, nothing happens.

func (*UintptrTable) WriteVerticalSequence

func (t *UintptrTable) WriteVerticalSequence(x, y *int, sequence []uintptr)

WriteVerticalSequence is a function that writes the specified values to the table starting from the specified coordinates (top = 0, 0) and continuing down the table in the vertical direction until either the sequence is exhausted or the end of the table is reached; at which point any remaining values in the sequence are ignored.

Due to implementation details, any value that would be written outside are ignored. As such, if x is out-of-bounds, the function does nothing and, if y is out-of-bounds, only out-of-bounds values are not written.

Parameters:

  • x: The x-coordinate of the starting cell. (Never changes)
  • y: The y-coordinate of the starting cell.
  • sequence: The sequence of cells to write to the table.

At the end of the function, the y coordinate points to the cell right below the last cell in the sequence that was written.

Example:

// [ a b c ]
// [ d e f ]
//
// seq := [ g h i ], x = 0, y = -1

WriteVerticalSequence(x, y, seq)

// [ h b c ]
// [ i e f ]
//
// x = 0, y = 2

As you can see, the 'g' value was ignored as it would be out-of-bounds. Finally, if either x or y is nil, the function does nothing.

Directories

Path Synopsis
cmd
This command generates a table of the given type implemented as a boundless table (i.e., out-of-bounds errors are not thrown).
This command generates a table of the given type implemented as a boundless table (i.e., out-of-bounds errors are not thrown).

Jump to

Keyboard shortcuts

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