Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply applies a variadic list of functional options to a given instance of type T. Parameters: - t: A pointer to the instance to be configured (*T). - opts: A variadic list of functional options (Option[T]). The function iterates over the provided options and applies each one to the instance.
func ApplyErr ¶
ApplyErr applies a variadic list of functional options to a given instance of type T, and returns an error if any option fails. Parameters: - t: A pointer to the instance to be configured (*T). - opts: A variadic list of functional options that may return errors (OptionErr[T]). Returns: - error: An error if any of the options return an error, otherwise nil. The function iterates over the provided options and applies each one to the instance. If any option returns an error, it is immediately returned and no further options are applied.
Types ¶
type MapSet ¶
type MapSet[T comparable] struct { // contains filtered or unexported fields }
MapSet is a generic implementation of the Set interface using a Go map. It ensures that elements are unique within the set.
func NewMapSet ¶
func NewMapSet[T comparable](size int) *MapSet[T]
NewMapSet creates and returns a new instance of MapSet with an initial capacity. Parameters: - size: The initial capacity of the map (int). Returns: - *MapSet[T]: A pointer to a newly created MapSet.
func (*MapSet[T]) Add ¶
func (s *MapSet[T]) Add(val T)
Add inserts a new element into the MapSet. If the element already exists, it does nothing. Parameters: - val: The value to be added to the set (T).
func (*MapSet[T]) Delete ¶
func (s *MapSet[T]) Delete(key T)
Delete removes an element from the MapSet. If the element does not exist, it does nothing. Parameters: - key: The value to be removed from the set (T).
type Option ¶
type Option[T any] func(t *T)
Option is a generic type for a functional option, which is a function that configures a given instance of type T.
type OptionErr ¶
OptionErr is a generic type for a functional option, which is a function that configures a given instance of type T and may return an error.
type Set ¶
type Set[T comparable] interface { Add(key T) // Adds a new element to the set. Delete(key T) // Deletes an element from the set. Exist(key T) bool // Checks if an element exists in the set. Keys() []T // Retrieves all elements in the set as a slice. }
Set is a generic interface representing a set data structure. It provides methods to add, delete, check the existence of elements, and retrieve all elements as a slice.