Documentation ¶
Overview ¶
Package container contains generic containers.
Package container provides generic map types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrExists is returned when the given element exists in the container. ErrExists = errors.New("element exists already") // ErrUnknown is returned when the given name doesn't exist in the container. ErrUnknown = errors.New("unknown element given") )
Functions ¶
This section is empty.
Types ¶
type List ¶
List is a list container of T.
type Map ¶
type Map[T any] struct { // contains filtered or unexported fields }
Map is a map container for function factories.
func (*Map[T]) Add ¶
Add adds a new factory function to this container. It returns ErrExists if the plugin already exists.
type Plugins ¶
Plugins is an alias around the Map type, for nicer plugin method names.
func NewPlugins ¶
NewPlugins creates a new plugins container of any type. Not concurency safe.
type SafeMap ¶
SafeMap is a concurrently safe generic map.
func NewSafeMap ¶
NewSafeMap creates a new concurrently map of any types.
func (*SafeMap[T]) Add ¶
Add adds a new factory function to this container. It returns ErrExists if the plugin already exists.
type Sorted ¶
type Sorted[T SortedElement] struct { // contains filtered or unexported fields }
Sorted is a sorted container.
func NewSorted ¶
func NewSorted[T SortedElement]() *Sorted[T]
NewSorted creates a new container that holds elements of type T sorted. Adds are costly as it sorts on each add, calls to Sorted() are free.
type SortedElement ¶
SortedElement needs to be implemented by every interface.