Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InSlice ¶
func InSlice[T comparable](v T, items []T) bool
InSlice checks if the target element exists in the given slice.
Types ¶
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
Set implements a generic collection of unique elements with type safety. The zero value is not usable, always create instances via NewSet constructor. This implementation is not thread-safe and requires external synchronization when used in concurrent environments.
func NewSet ¶
func NewSet[T comparable](capacity int, elements ...T) *Set[T]
NewSet constructs a Set instance with optional initial capacity and elements.
func (*Set[T]) Elements ¶
func (set *Set[T]) Elements() []T
Elements returns all set members as a new slice.
Click to show internal directories.
Click to hide internal directories.