Documentation ¶
Index ¶
- type Set
- func (s *Set[T, H]) Append(items ...T)
- func (s *Set[T, H]) Clear()
- func (s *Set[T, H]) Empty() bool
- func (s *Set[T, H]) Has(item T) bool
- func (s *Set[T, H]) Items() []T
- func (s *Set[T, H]) ItemsMutable() []T
- func (s *Set[T, H]) Length() int
- func (s *Set[T, H]) Prepend(items ...T)
- func (s *Set[T, H]) String() string
- type SimpleSet
- func (s *SimpleSet[T, H]) Append(items ...T)
- func (s *SimpleSet[T, H]) Clear()
- func (s *SimpleSet[T, H]) Empty() bool
- func (s *SimpleSet[T, H]) Has(item T) bool
- func (s *SimpleSet[T, H]) Items() []T
- func (s *SimpleSet[T, H]) ItemsMutable() []T
- func (s *SimpleSet[T, H]) Length() int
- func (s *SimpleSet[T, H]) Prepend(items ...T)
- func (s *SimpleSet[T, H]) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[T, H comparable] struct { *SimpleSet[T, H] // contains filtered or unexported fields }
Set is a generic thread-safe data structure representing a unique collection of items, with synchronized access.
func New ¶
func New[T comparable](items ...T) *Set[T, T]
func NewWithHash ¶
func NewWithHash[T, H comparable](hashFunc func(T) H, items ...T) *Set[T, H]
func (*Set[T, H]) Append ¶
func (s *Set[T, H]) Append(items ...T)
Append adds unique items in order to the end of the set
func (*Set[T, H]) Items ¶
func (s *Set[T, H]) Items() []T
Items returns a copy of the underlying item array
func (*Set[T, H]) ItemsMutable ¶
func (s *Set[T, H]) ItemsMutable() []T
ItemsMutable returns a direct reference to the underlying item array. Use and modify at your own risk.
type SimpleSet ¶
type SimpleSet[T, HashType comparable] struct { // contains filtered or unexported fields }
SimpleSet is a generic data structure representing a unique collection of items. It is not thread safe, concurrent reads and writes will cause a panic. Use this version only if this is not a concern.
func NewSimpleSet ¶
func NewSimpleSet[T comparable](items ...T) *SimpleSet[T, T]
New builds a new set object
func NewSimpleSetWithHash ¶
func NewSimpleSetWithHash[T comparable, HashType comparable](hashFunc func(T) HashType, items ...T) *SimpleSet[T, HashType]
New builds a new set object
func (*SimpleSet[T, H]) Append ¶
func (s *SimpleSet[T, H]) Append(items ...T)
Append adds unique items in order to the end of the set
func (*SimpleSet[T, H]) Items ¶
func (s *SimpleSet[T, H]) Items() []T
Items returns a copy of the underlying item array
func (*SimpleSet[T, H]) ItemsMutable ¶
func (s *SimpleSet[T, H]) ItemsMutable() []T
ItemsMutable returns a direct reference to the underlying item array. Use and modify at your own risk.