stmutil

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 6 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextDoneVar

func ContextDoneVar(ctx context.Context) (*stm.Var[bool], func())

Returns an STM var that contains a bool equal to `ctx.Err != nil`, and a cancel function to be called when the user is no longer interested in the var.

func GetLeft

func GetLeft(l, _ any) any

Types

type KeyConstraint added in v0.5.0

type KeyConstraint interface {
	comparable
}

This is the type constraint for keys passed through from github.com/benbjohnson/immutable.

type Lenner

type Lenner interface {
	Len() int
}

type Map

type Map[K KeyConstraint, V any] struct {
	*immutable.Map[K, V]
}

func (Map[K, V]) Delete

func (m Map[K, V]) Delete(x K) Mappish[K, V]

func (Map[K, V]) Iter

func (sm Map[K, V]) Iter(cb iter.Callback)

func (Map[K, V]) Range

func (sm Map[K, V]) Range(f func(K, V) bool)

func (Map[K, V]) Set

func (m Map[K, V]) Set(key K, value V) Mappish[K, V]

type Mappish

type Mappish[K, V any] interface {
	Set(K, V) Mappish[K, V]
	Delete(key K) Mappish[K, V]
	Get(key K) (V, bool)
	Range(func(K, V) bool)
	Len() int
	iter.Iterable
}

func NewMap

func NewMap[K KeyConstraint, V any]() Mappish[K, V]

func NewSortedMap

func NewSortedMap[K KeyConstraint, V any](less lessFunc[K]) Mappish[K, V]

type Settish

type Settish[K KeyConstraint] interface {
	Add(K) Settish[K]
	Delete(K) Settish[K]
	Contains(K) bool
	Range(func(K) bool)
	iter.Iterable
	Len() int
}

func NewSet

func NewSet[K KeyConstraint]() Settish[K]

func NewSortedSet

func NewSortedSet[K KeyConstraint](lesser lessFunc[K]) Settish[K]

type SortedMap

type SortedMap[K KeyConstraint, V any] struct {
	*immutable.SortedMap[K, V]
}

func (SortedMap[K, V]) Delete

func (sm SortedMap[K, V]) Delete(key K) Mappish[K, V]

func (SortedMap[K, V]) Iter

func (sm SortedMap[K, V]) Iter(cb iter.Callback)

func (SortedMap[K, V]) Range

func (sm SortedMap[K, V]) Range(f func(key K, value V) bool)

func (SortedMap[K, V]) Set

func (sm SortedMap[K, V]) Set(key K, value V) Mappish[K, V]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL