Documentation
¶
Overview ¶
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 InternalTuple ¶
type InternalTuple[T any] struct { // contains filtered or unexported fields }
InternalTuple represents a fixed-length collection of values of type T. It supports safe element access, mutation, and conversion to/from slices.
func FromSlice ¶
func FromSlice[T any](s []T) *InternalTuple[T]
FromSlice creates a new InternalTuple by copying the contents of the provided slice. The resulting Tuple has the same length as the input slice.
func New ¶
func New[T any](vars ...T) *InternalTuple[T]
New creates a new InternalTuple from the given variadic values. The values are copied to ensure the Tuple does not alias external data.
func (*InternalTuple[T]) Get ¶
func (t *InternalTuple[T]) Get(index int) (T, bool)
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 (*InternalTuple[T]) Len ¶
func (t *InternalTuple[T]) Len() int
Len returns the number of elements in the InternalTuple.
func (*InternalTuple[T]) Set ¶
func (t *InternalTuple[T]) Set(index int, v T) bool
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.
func (*InternalTuple[T]) String ¶
func (t *InternalTuple[T]) String() string
String returns a string representation of the InternalTuple's contents.
func (*InternalTuple[T]) ToSlice ¶
func (t *InternalTuple[T]) ToSlice() []T
ToSlice returns a copy of the InternalTuple's internal values as a slice.