Documentation
¶
Index ¶
- type Map
- func (sm *Map[T, U]) Copy() *Map[T, U]
- func (sm *Map[T, U]) Delete(key T)
- func (sm *Map[T, U]) Entry() iter.Seq2[T, U]
- func (sm *Map[T, U]) Get(key T) (U, bool)
- func (sm *Map[T, U]) GetMap() map[T]U
- func (sm *Map[T, U]) Len() int
- func (sm *Map[T, U]) Reset()
- func (sm *Map[T, U]) Set(key T, val U) error
- type Slice
- type Table
- func (t *Table[T]) CellAt(x, y int) T
- func (t *Table[T]) Free()
- func (t *Table[T]) Height() int
- func (t *Table[T]) ResizeHeight(new_height int) error
- func (t *Table[T]) ResizeWidth(new_width int) error
- func (t *Table[T]) Row() iter.Seq2[int, []T]
- func (t *Table[T]) SetCellAt(cell T, x, y int)
- func (t *Table[T]) Width() int
- type Var
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[T comparable, U any] struct { // contains filtered or unexported fields }
Map is a thread-safe map. To create an empty map, use the `sm := new(rws.Map[T, U])` constructor.
func (*Map[T, U]) Copy ¶
Copy is a method that returns a copy of the Map.
Returns:
- *Map[T, U]: A copy of the Map. An empty Map if the receiver is nil.
func (*Map[T, U]) Delete ¶
func (sm *Map[T, U]) Delete(key T)
Delete removes a key from the map. Does nothing if the key does not exist in the map.
Parameters:
- key: The key to remove.
func (*Map[T, U]) Entry ¶
Entry is a method that returns an iterator over the entries in the Map.
Returns:
- iter.Seq2[T, U]: An iterator over the entries in the Map. Never returns nil.
func (*Map[T, U]) Get ¶
Get retrieves a value from the map.
Parameters:
- key: The key to retrieve the value.
Returns:
- U: The value associated with the key.
- bool: A boolean indicating if the key exists in the map.
func (*Map[T, U]) GetMap ¶
func (sm *Map[T, U]) GetMap() map[T]U
GetMap returns the underlying map.
Returns:
- map[T]U: The underlying map. Nil if the receiver is nil.
type Slice ¶
type Slice[T any] struct { // contains filtered or unexported fields }
Slice is a slice that can be read and written safely. It must be created using the `s := new(rws.Slice[T])` constructor.
func (*Slice[T]) Append ¶
Append appends a slice to the Slice.
Parameters:
- slice: The slice to append.
Returns:
- error: Nil if the receiver is nil.
Errors:
- errors.ErrNilReceiver: If the receiver is nil.
func (*Slice[T]) Copy ¶
Copy returns a deep copy of the slice. If the receiver is nil, a new empty slice is returned.
Returns:
- *Slice[T]: The copy of the slice. Never returns nil.
func (*Slice[T]) Free ¶
func (s *Slice[T]) Free()
Free releases any resources associated with the Slice.
type Table ¶
type Table[T any] struct { // contains filtered or unexported fields }
Table is a boundless table. This means that any operation done to out-of-bounds cells will not cause any error. The table is safe for concurrent use.
func NewTable ¶
NewTable creates a new Table with a width and height.
Parameters:
- width: The width of the table.
- height: The height of the table.
Returns:
- *Table: The new Table.
- error: If the table could not be created.
Errors:
- errors.BadParameterError: If width or height is negative.
func (*Table[T]) CellAt ¶
CellAt returns the cell at the specified position.
Parameters:
- x: The x position of the cell.
- y: The y position of the cell.
Returns:
- T: The cell at the specified position. The zero value if the receiver is nil or the position is out of bounds.
func (*Table[T]) Free ¶
func (t *Table[T]) Free()
Free releases any resources associated with the Table.
func (*Table[T]) Height ¶
Height returns the height of the table.
Returns:
- int: The height of the table. 0 if the receiver is nil.
func (*Table[T]) ResizeHeight ¶
ResizeHeight resizes the height of the table. The height is not resized if the receiver is nil or the new height is the same as the current height.
Parameters:
- new_height: The new height of the table.
Returns:
- error: If the table could not be resized.
Errors:
- gers.BadParameterError: If new_height is negative.
func (*Table[T]) ResizeWidth ¶
ResizeWidth resizes the width of the table. The width is not resized if the receiver is nil or the new width is the same as the current width.
Parameters:
- new_width: The new width of the table.
Returns:
- error: If the table could not be resized.
Errors:
- gers.BadParameterError: If new_width is negative.
func (*Table[T]) Row ¶
Row returns an iterator over the rows in the table.
Returns:
- iter.Seq2[int, []T]: An iterator over the rows in the table. Never returns nil.
type Var ¶
type Var[T any] struct { // contains filtered or unexported fields }
Var is a variable that can be read and written safely. To create a Var with the zero value, use the `v := new(rws.Var[T])` constructor.
func New ¶
New creates a new Var.
Parameters:
- data: The initial value of the variable.
Returns:
- *Var[T]: The new Var. Never returns nil.
func (*Var[T]) Copy ¶
Copy returns a copy of the Var.
Returns:
- *Var[T]: A copy of the Var. Never returns nil.
If the receiver is nil, a new Var is returned.
func (*Var[T]) Edit ¶
Edit edits the value of the variable. Does nothing if the function is nil.
Parameters:
- fn: The function to edit the value.
Returns:
- error: An error if the receiver is nil.
func (*Var[T]) Get ¶
Get returns the value of the variable.
Returns:
- T: The value.
- error: An error if the receiver is nil.
Errors:
- common.ErrNilReceiver: If the receiver is nil.