Documentation
¶
Overview ¶
Package tuple provides a generic, fixed-size tuple type with safe access and mutation.
Package tuple provides a generic, fixed-size tuple type with safe access and mutation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SyncTuple ¶
type SyncTuple[T any] struct { // contains filtered or unexported fields }
SyncTuple represents a fixed-length collection of values of type T with thread-safety. It supports safe element access, mutation, and conversion to/from slices.
func NewSync ¶
New creates a new SyncTuple from the given variadic values. The values are copied to ensure the SyncTuple does not alias external data.
func SyncFromSlice ¶
FromSlice creates a new SyncTuple by copying the contents of the provided slice. The resulting Tuple has the same length as the input slice.
func (*SyncTuple[T]) Get ¶
Get returns the element at the specified index and a boolean indicating success. If the index is out of bounds, the zero value of T and false are returned.
func (*SyncTuple[T]) Set ¶
Set updates the element at the specified index to the given value. It returns true if the operation was successful, or false if the index was out of bounds.
type Tuple ¶
type Tuple[T any] struct { // contains filtered or unexported fields }
Tuple represents a fixed-length collection of values of type T. It supports safe element access, mutation, and conversion to/from slices.
func FromSlice ¶
FromSlice creates a new Tuple by copying the contents of the provided slice. The resulting Tuple has the same length as the input slice.
func New ¶
New creates a new Tuple from the given variadic values. The values are copied to ensure the Tuple does not alias external data.
func (*Tuple[T]) Get ¶
Get returns the element at the specified index and a boolean indicating success. If the index is out of bounds, the zero value of T and false are returned.
func (*Tuple[T]) Set ¶
Set updates the element at the specified index to the given value. It returns true if the operation was successful, or false if the index was out of bounds.