Documentation
¶
Overview ¶
Package container contains generic containers.
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 Hashable ¶ added in v0.1.0
type Hashable interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | ~string
}
Hashable is used as the key for maps.
type List ¶
List is a list container of T.
type Map ¶
Map is a map container for function factories.
func (*Map[K, T]) Add ¶
Add adds a new factory function to this container. It returns false if the element already exists.
func (*Map[K, T]) Del ¶ added in v0.1.0
Del calls delete(me, key) and returns true if the element existed.
type Pool ¶ added in v0.1.0
type Pool[T any] struct { // contains filtered or unexported fields }
A Pool is a generic wrapper around a sync.Pool.
func NewPool ¶ added in v0.1.0
NewPool creates a new Pool with the provided new function.
The equivalent sync.Pool construct is "sync.Pool{New: fn}".
type PriorityList ¶ added in v0.1.1
type PriorityList[T any] struct { // contains filtered or unexported fields }
PriorityList is a priority list of elements.
func NewPriorityList ¶ added in v0.1.1
func NewPriorityList[T any]() *PriorityList[T]
NewPriorityList creates a new priority list of elements.
func (*PriorityList[T]) Add ¶ added in v0.1.1
func (c *PriorityList[T]) Add(element T, priority int) error
Add adds a new element with the given priority to the list.
type PriorityListElement ¶ added in v0.1.1
PriorityListElement needs to be implemented by every interface.
type Priorizeable ¶ added in v0.1.0
type Priorizeable interface {
Priority() int
}
Priorizeable has to be implemented by elements that use container.Priorize*.
type SafeMap ¶
SafeMap is a wrapper for "github.com/cornelk/hashmap".
func NewSafeMap ¶
NewSafeMap creates a wrapper for "github.com/cornelk/hashmap".