Documentation
¶
Overview ¶
Package optimistic contains a set of "lock-free" data types that use optimistic concurrency control to allow atomic mutations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comparator ¶
type Comparator[T any] interface { // Compare performs a 3-way comparison of a and b. Compare(a, b T) int }
Comparator is a type that compares two values.
type LessComparator ¶
type LessComparator[T interface{ Less(T) bool }] struct{}
LessComparator is a Comparator for types that implement a LessComparator() method.
type OrderedComparator ¶
type OrderedComparator[T constraints.Ordered] struct{}
OrderedComparator is a Comparator that compares values that match the constraints.OrderedComparator constraint.
func (OrderedComparator[T]) Compare ¶
func (OrderedComparator[T]) Compare(a, b T) int
Compare performs a 3-way comparison of a and b.
type OrderedSet ¶
type OrderedSet[M any, C Comparator[M]] struct { Comparator C // contains filtered or unexported fields }
OrderedSet is a read-optimized lock-free ordered set.
func (*OrderedSet[M, C]) Delete ¶
func (s *OrderedSet[M, C]) Delete(m M)
Delete removes a member from the set.
func (*OrderedSet[M, C]) Has ¶
func (s *OrderedSet[M, C]) Has(m M) bool
Has returns true if m is a member of the set.
func (*OrderedSet[M, C]) Len ¶
func (s *OrderedSet[M, C]) Len() int
Len returns the number of members in the set.
func (*OrderedSet[M, C]) Members ¶
func (s *OrderedSet[M, C]) Members() []M
Members returns the members of the set, in order. The returned slice must not be modified.
type Value ¶
type Value[T any] struct { // contains filtered or unexported fields }
Value is a value protected by optimistic concurrency control.