Documentation ¶
Index ¶
- func Filter[T any](f func(index int, v T) bool, values ...T) []T
- func Map[T any, U any](f func(index int, v T) U, values ...T) []U
- func Or[T comparable](value T, orValue T) T
- func Retry(config *RetryConfig, executor func() error) error
- func SigFigDur(t time.Duration, sigFigs int) string
- func Unique[T comparable](values ...T) []T
- type IndexedDequeIterator
- type IndexedDequeue
- func (iq *IndexedDequeue) Find(pattern string) []*IndexedDequeueLink
- func (iq *IndexedDequeue) GetIter() *IndexedDequeIterator
- func (iq *IndexedDequeue) Pop() string
- func (iq *IndexedDequeue) Push(value string)
- func (iq *IndexedDequeue) RemoveItem(links ...*IndexedDequeueLink)
- func (iq *IndexedDequeue) Size() int
- type IndexedDequeueLink
- type Link
- type OrderedMap
- type OrderedMapIter
- type RetryConfig
- type Set
- func (s *Set[T]) Add(values ...T)
- func (s *Set[T]) Copy() *Set[T]
- func (s *Set[T]) Difference(set ...*Set[T]) *Set[T]
- func (s *Set[T]) Has(value T) bool
- func (s *Set[T]) Intersect(set *Set[T]) *Set[T]
- func (s *Set[T]) Items() []T
- func (s *Set[T]) Pop() any
- func (s *Set[T]) Remove(value T)
- func (s *Set[T]) Size() int
- type SortedList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Or ¶ added in v0.1.4
func Or[T comparable](value T, orValue T) T
Or returns the orValue when value is the zero value for a given type
func Retry ¶ added in v0.2.0
func Retry(config *RetryConfig, executor func() error) error
Retry will execute the provided executor function multiple times with an interim delay, reporting the final error status in the event of a terminal failure
func SigFigDur ¶ added in v0.1.2
SigFigDur renders duration to a fixed number of significant figures, independent of the unit of measure.
func Unique ¶
func Unique[T comparable](values ...T) []T
Unique returns a slice from the original containing only unique elements
Types ¶
type IndexedDequeIterator ¶ added in v0.6.1
type IndexedDequeIterator struct {
// contains filtered or unexported fields
}
func (*IndexedDequeIterator) Next ¶ added in v0.6.1
func (iqi *IndexedDequeIterator) Next() bool
func (*IndexedDequeIterator) ReverseNext ¶ added in v0.6.1
func (iqi *IndexedDequeIterator) ReverseNext() bool
func (*IndexedDequeIterator) Value ¶ added in v0.6.1
func (iqi *IndexedDequeIterator) Value() string
type IndexedDequeue ¶ added in v0.6.0
type IndexedDequeue struct {
// contains filtered or unexported fields
}
func NewIndexedDequeue ¶ added in v0.6.0
func NewIndexedDequeue(items ...string) *IndexedDequeue
NewIndexedDequeue creates an indexed deque, whereby items can be accessed in constant time from the head or tail, and arbitrary items can be accessed in near constant time using a string lookup, where lookup time varies slightly by the number of matching candidates. pop => prev(nil) <-- tail <-- prev next --> head --> next(nil) <= push
func (*IndexedDequeue) Find ¶ added in v0.6.0
func (iq *IndexedDequeue) Find(pattern string) []*IndexedDequeueLink
func (*IndexedDequeue) GetIter ¶ added in v0.6.1
func (iq *IndexedDequeue) GetIter() *IndexedDequeIterator
GetIter returns an iterator
func (*IndexedDequeue) Pop ¶ added in v0.6.0
func (iq *IndexedDequeue) Pop() string
func (*IndexedDequeue) Push ¶ added in v0.6.0
func (iq *IndexedDequeue) Push(value string)
func (*IndexedDequeue) RemoveItem ¶ added in v0.6.0
func (iq *IndexedDequeue) RemoveItem(links ...*IndexedDequeueLink)
func (*IndexedDequeue) Size ¶ added in v0.6.0
func (iq *IndexedDequeue) Size() int
type IndexedDequeueLink ¶ added in v0.6.0
type Link ¶ added in v0.4.0
type Link[K comparable, V any] struct { Key K Value V Next *Link[K, V] Prev *Link[K, V] }
type OrderedMap ¶ added in v0.4.0
type OrderedMap[K comparable, V any] struct { // contains filtered or unexported fields }
func NewOrderedMap ¶ added in v0.4.0
func NewOrderedMap[K comparable, V any]() *OrderedMap[K, V]
func (*OrderedMap[K, V]) Delete ¶ added in v0.4.0
func (om *OrderedMap[K, V]) Delete(key K)
func (*OrderedMap[K, V]) Get ¶ added in v0.4.0
func (om *OrderedMap[K, V]) Get(key K) (V, bool)
func (*OrderedMap[K, V]) GetIter ¶ added in v0.4.0
func (om *OrderedMap[K, V]) GetIter() *OrderedMapIter[K, V]
GetIter returns an iterator which allows for forward or reverse iteration through the key/value pairs as they were added to the collection
func (*OrderedMap[K, V]) Length ¶ added in v0.4.0
func (om *OrderedMap[K, V]) Length() int
func (*OrderedMap[K, V]) Put ¶ added in v0.4.0
func (om *OrderedMap[K, V]) Put(key K, value V)
type OrderedMapIter ¶ added in v0.5.0
type OrderedMapIter[K comparable, V any] struct { // contains filtered or unexported fields }
func (*OrderedMapIter[K, V]) Key ¶ added in v0.5.0
func (i *OrderedMapIter[K, V]) Key() K
func (*OrderedMapIter[K, V]) Next ¶ added in v0.5.0
func (i *OrderedMapIter[K, V]) Next() bool
Next advances to the next position in the iterator. This must be called before the iterator's Key() or Value() functions can be consumed. This lends well to using Next() in a for loop
func (*OrderedMapIter[K, V]) ReverseNext ¶ added in v0.5.0
func (i *OrderedMapIter[K, V]) ReverseNext() bool
ReverseNext advances to the next position in the iterator, starting from the end going to the beginning. This must be called before the iterator's Key() or Value() functions can be consumed. This lends well to using ReverseNext() in a for loop
func (*OrderedMapIter[K, V]) Value ¶ added in v0.5.0
func (i *OrderedMapIter[K, V]) Value() V
type RetryConfig ¶ added in v0.2.0
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
func Intersect ¶ added in v0.3.1
func Intersect[T comparable](set ...*Set[T]) *Set[T]
Intersect returns the intersection of all provided sets
func NewSet ¶
func NewSet[T comparable](values ...T) *Set[T]
NewSet creates a new set, initialized with values
func NewSetFromMap ¶ added in v0.2.0
func NewSetFromMap[T comparable, X any](values map[T]X) *Set[T]
func Union ¶ added in v0.3.1
func Union[T comparable](set ...*Set[T]) *Set[T]
Union returns a new set that is a union of the members of the provided sets
func (*Set[T]) Difference ¶ added in v0.3.1
func (*Set[T]) Items ¶ added in v0.1.1
func (s *Set[T]) Items() []T
Items returns a slice of the items in the set
type SortedList ¶ added in v0.5.0
func NewSortedList ¶ added in v0.5.0
func NewSortedList[T cmp.Ordered](items ...T) *SortedList[T]
NewSortedList constructs a sorted list. A sorted list maintains order upon every added item, making it ideal for accesing the smallest and largest items at any given time.
func (*SortedList[T]) Extend ¶ added in v0.5.0
func (l *SortedList[T]) Extend(items ...T)
func (*SortedList[T]) Get ¶ added in v0.5.0
func (l *SortedList[T]) Get(index int) T
func (*SortedList[T]) Largest ¶ added in v0.5.0
func (l *SortedList[T]) Largest() T
func (*SortedList[T]) Length ¶ added in v0.5.0
func (l *SortedList[T]) Length() int
func (*SortedList[T]) PopLargest ¶ added in v0.5.0
func (l *SortedList[T]) PopLargest() T
func (*SortedList[T]) PopSmallest ¶ added in v0.5.0
func (l *SortedList[T]) PopSmallest() T
func (*SortedList[T]) Smallest ¶ added in v0.5.0
func (l *SortedList[T]) Smallest() T