Documentation
¶
Index ¶
- Variables
- type Boxed
- func (set Boxed[T]) Add(item T)
- func (set Boxed[T]) AddAll(itemArray []T)
- func (set Boxed[T]) AddSet(other Set[T])
- func (set Boxed[T]) Clear()
- func (set Boxed[T]) Contains(item T) bool
- func (set Boxed[T]) ContainsAll(other Set[T]) bool
- func (set Boxed[T]) Copy() Set[T]
- func (set Boxed[T]) Discard(item T)
- func (set Boxed[T]) Equals(other Set[T]) bool
- func (set Boxed[T]) Iter(visitor func(item T) error)
- func (set Boxed[T]) Len() int
- func (set Boxed[T]) Slice() (s []T)
- func (set Boxed[T]) String() string
- type Set
- type Typed
- func (set Typed[T]) Add(item T)
- func (set Typed[T]) AddAll(itemArray []T)
- func (set Typed[T]) AddSet(other Set[T])
- func (set Typed[T]) Clear()
- func (set Typed[T]) Contains(item T) bool
- func (set Typed[T]) ContainsAll(other Set[T]) bool
- func (set Typed[T]) Copy() Set[T]
- func (set Typed[T]) Discard(item T)
- func (set Typed[T]) Equals(other Set[T]) bool
- func (set Typed[T]) Iter(visitor func(item T) error)
- func (set Typed[T]) Len() int
- func (set Typed[T]) Slice() (s []T)
- func (set Typed[T]) String() string
Constants ¶
This section is empty.
Variables ¶
var ( StopIteration = errors.New("stop iteration") RemoveItem = errors.New("remove item") )
Functions ¶
This section is empty.
Types ¶
type Boxed ¶
func FromArrayBoxed ¶
func NewBoxed ¶
NewBoxed creates a new "boxed" Set, where the items stored in the set are boxed inside an interface. The values placed into the set must be comparable (i.e. suitable for use as a map key). This is checked at runtime and the code will panic on trying to add a non-comparable entry.
This implementation exists because Go's generics currently have a gap. The type set of the "comparable" constraint currently doesn't include interface types, which under Go's normal rules _are_ comparable (but may panic at runtime if the interface happens to contain a non-comparable object). If possible use a typed map via New() or From(); use this if you really need a Set[any] or Set[SomeInterface].
func (Boxed[T]) ContainsAll ¶
type Set ¶
type Typed ¶
type Typed[T comparable] map[T]v
func From ¶
func From[T comparable](members ...T) Typed[T]
func FromArray ¶
func FromArray[T comparable](membersArray []T) Typed[T]
func New ¶
func New[T comparable]() Typed[T]