Documentation ¶
Overview ¶
Package skipset is a high-performance, scalable, concurrent-safe set based on skip-list. In the typical pattern(100000 operations, 90%CONTAINS 9%Add 1%Remove, 8C16T), the skipset up to 15x faster than the built-in sync.Map.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FuncSet ¶ added in v0.12.0
type FuncSet[T any] struct { // contains filtered or unexported fields }
FuncSet represents a set based on skip list.
func NewFloat32 ¶
NewFloat32 returns an empty skip set in ascending order.
func NewFloat32Desc ¶ added in v0.9.0
NewFloat32Desc returns an empty skip set in descending order.
func NewFloat64 ¶
NewFloat64 returns an empty skip set in ascending order.
func NewFloat64Desc ¶ added in v0.9.0
NewFloat64Desc returns an empty skip set in descending order.
func NewFunc ¶ added in v0.12.0
NewFunc returns an empty skip set in ascending order.
Note that the less function requires a strict weak ordering, see https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings, or undefined behavior will happen.
func (*FuncSet[T]) Add ¶ added in v0.12.0
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
type Int32Set ¶
type Int32Set struct {
// contains filtered or unexported fields
}
Int32Set represents a set based on skip list.
func (*Int32Set) Add ¶ added in v0.8.0
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
type Int32SetDesc ¶ added in v0.9.0
type Int32SetDesc struct {
// contains filtered or unexported fields
}
Int32SetDesc represents a set based on skip list.
func NewInt32Desc ¶ added in v0.9.0
func NewInt32Desc() *Int32SetDesc
NewInt32Desc returns an empty skip set in descending order.
func (*Int32SetDesc) Add ¶ added in v0.9.0
func (s *Int32SetDesc) Add(value int32) bool
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
func (*Int32SetDesc) Contains ¶ added in v0.9.0
func (s *Int32SetDesc) Contains(value int32) bool
Contains checks if the value is in the skip set.
func (*Int32SetDesc) Len ¶ added in v0.9.0
func (s *Int32SetDesc) Len() int
Len returns the length of this skip set.
func (*Int32SetDesc) Range ¶ added in v0.9.0
func (s *Int32SetDesc) Range(f func(value int32) bool)
Range calls f sequentially for each value present in the skip set. If f returns false, range stops the iteration.
func (*Int32SetDesc) Remove ¶ added in v0.9.0
func (s *Int32SetDesc) Remove(value int32) bool
Remove removes a node from the skip set.
type Int64Set ¶
type Int64Set struct {
// contains filtered or unexported fields
}
Int64Set represents a set based on skip list.
func (*Int64Set) Add ¶ added in v0.8.0
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
type Int64SetDesc ¶ added in v0.9.0
type Int64SetDesc struct {
// contains filtered or unexported fields
}
Int64SetDesc represents a set based on skip list.
func NewInt64Desc ¶ added in v0.9.0
func NewInt64Desc() *Int64SetDesc
NewInt64Desc returns an empty skip set in descending order.
func (*Int64SetDesc) Add ¶ added in v0.9.0
func (s *Int64SetDesc) Add(value int64) bool
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
func (*Int64SetDesc) Contains ¶ added in v0.9.0
func (s *Int64SetDesc) Contains(value int64) bool
Contains checks if the value is in the skip set.
func (*Int64SetDesc) Len ¶ added in v0.9.0
func (s *Int64SetDesc) Len() int
Len returns the length of this skip set.
func (*Int64SetDesc) Range ¶ added in v0.9.0
func (s *Int64SetDesc) Range(f func(value int64) bool)
Range calls f sequentially for each value present in the skip set. If f returns false, range stops the iteration.
func (*Int64SetDesc) Remove ¶ added in v0.9.0
func (s *Int64SetDesc) Remove(value int64) bool
Remove removes a node from the skip set.
type IntSet ¶
type IntSet struct {
// contains filtered or unexported fields
}
IntSet represents a set based on skip list.
func (*IntSet) Add ¶ added in v0.8.0
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
type IntSetDesc ¶ added in v0.9.0
type IntSetDesc struct {
// contains filtered or unexported fields
}
IntSetDesc represents a set based on skip list.
func NewIntDesc ¶ added in v0.9.0
func NewIntDesc() *IntSetDesc
NewIntDesc returns an empty skip set in descending order.
func (*IntSetDesc) Add ¶ added in v0.9.0
func (s *IntSetDesc) Add(value int) bool
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
func (*IntSetDesc) Contains ¶ added in v0.9.0
func (s *IntSetDesc) Contains(value int) bool
Contains checks if the value is in the skip set.
func (*IntSetDesc) Len ¶ added in v0.9.0
func (s *IntSetDesc) Len() int
Len returns the length of this skip set.
func (*IntSetDesc) Range ¶ added in v0.9.0
func (s *IntSetDesc) Range(f func(value int) bool)
Range calls f sequentially for each value present in the skip set. If f returns false, range stops the iteration.
func (*IntSetDesc) Remove ¶ added in v0.9.0
func (s *IntSetDesc) Remove(value int) bool
Remove removes a node from the skip set.
type OrderedSet ¶ added in v0.12.0
type OrderedSet[T ordered] struct {
// contains filtered or unexported fields
}
OrderedSet represents a set based on skip list.
func New ¶ added in v0.12.0
func New[T ordered]() *OrderedSet[T]
New returns an empty skip set in ascending order.
func (*OrderedSet[T]) Add ¶ added in v0.12.0
func (s *OrderedSet[T]) Add(value T) bool
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
func (*OrderedSet[T]) Contains ¶ added in v0.12.0
func (s *OrderedSet[T]) Contains(value T) bool
Contains checks if the value is in the skip set.
func (*OrderedSet[T]) Len ¶ added in v0.12.0
func (s *OrderedSet[T]) Len() int
Len returns the length of this skip set.
func (*OrderedSet[T]) Range ¶ added in v0.12.0
func (s *OrderedSet[T]) Range(f func(value T) bool)
Range calls f sequentially for each value present in the skip set. If f returns false, range stops the iteration.
func (*OrderedSet[T]) Remove ¶ added in v0.12.0
func (s *OrderedSet[T]) Remove(value T) bool
Remove removes a node from the skip set.
type OrderedSetDesc ¶ added in v0.12.0
type OrderedSetDesc[T ordered] struct {
// contains filtered or unexported fields
}
OrderedSetDesc represents a set based on skip list.
func NewDesc ¶ added in v0.12.0
func NewDesc[T ordered]() *OrderedSetDesc[T]
NewDesc returns an empty skip set in descending order.
func (*OrderedSetDesc[T]) Add ¶ added in v0.12.0
func (s *OrderedSetDesc[T]) Add(value T) bool
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
func (*OrderedSetDesc[T]) Contains ¶ added in v0.12.0
func (s *OrderedSetDesc[T]) Contains(value T) bool
Contains checks if the value is in the skip set.
func (*OrderedSetDesc[T]) Len ¶ added in v0.12.0
func (s *OrderedSetDesc[T]) Len() int
Len returns the length of this skip set.
func (*OrderedSetDesc[T]) Range ¶ added in v0.12.0
func (s *OrderedSetDesc[T]) Range(f func(value T) bool)
Range calls f sequentially for each value present in the skip set. If f returns false, range stops the iteration.
func (*OrderedSetDesc[T]) Remove ¶ added in v0.12.0
func (s *OrderedSetDesc[T]) Remove(value T) bool
Remove removes a node from the skip set.
type StringSet ¶
type StringSet struct {
// contains filtered or unexported fields
}
StringSet represents a set based on skip list.
func NewString ¶
func NewString() *StringSet
NewString returns an empty skip set in ascending order.
func (*StringSet) Add ¶ added in v0.8.0
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
type StringSetDesc ¶ added in v0.12.0
type StringSetDesc struct {
// contains filtered or unexported fields
}
StringSetDesc represents a set based on skip list.
func NewStringDesc ¶ added in v0.12.0
func NewStringDesc() *StringSetDesc
NewStringDesc returns an empty skip set in descending order.
func (*StringSetDesc) Add ¶ added in v0.12.0
func (s *StringSetDesc) Add(value string) bool
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
func (*StringSetDesc) Contains ¶ added in v0.12.0
func (s *StringSetDesc) Contains(value string) bool
Contains checks if the value is in the skip set.
func (*StringSetDesc) Len ¶ added in v0.12.0
func (s *StringSetDesc) Len() int
Len returns the length of this skip set.
func (*StringSetDesc) Range ¶ added in v0.12.0
func (s *StringSetDesc) Range(f func(value string) bool)
Range calls f sequentially for each value present in the skip set. If f returns false, range stops the iteration.
func (*StringSetDesc) Remove ¶ added in v0.12.0
func (s *StringSetDesc) Remove(value string) bool
Remove removes a node from the skip set.
type Uint32Set ¶
type Uint32Set struct {
// contains filtered or unexported fields
}
Uint32Set represents a set based on skip list.
func NewUint32 ¶
func NewUint32() *Uint32Set
NewUint32 returns an empty skip set in ascending order.
func (*Uint32Set) Add ¶ added in v0.8.0
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
type Uint32SetDesc ¶ added in v0.9.0
type Uint32SetDesc struct {
// contains filtered or unexported fields
}
Uint32SetDesc represents a set based on skip list.
func NewUint32Desc ¶ added in v0.9.0
func NewUint32Desc() *Uint32SetDesc
NewUint32Desc returns an empty skip set in descending order.
func (*Uint32SetDesc) Add ¶ added in v0.9.0
func (s *Uint32SetDesc) Add(value uint32) bool
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
func (*Uint32SetDesc) Contains ¶ added in v0.9.0
func (s *Uint32SetDesc) Contains(value uint32) bool
Contains checks if the value is in the skip set.
func (*Uint32SetDesc) Len ¶ added in v0.9.0
func (s *Uint32SetDesc) Len() int
Len returns the length of this skip set.
func (*Uint32SetDesc) Range ¶ added in v0.9.0
func (s *Uint32SetDesc) Range(f func(value uint32) bool)
Range calls f sequentially for each value present in the skip set. If f returns false, range stops the iteration.
func (*Uint32SetDesc) Remove ¶ added in v0.9.0
func (s *Uint32SetDesc) Remove(value uint32) bool
Remove removes a node from the skip set.
type Uint64Set ¶
type Uint64Set struct {
// contains filtered or unexported fields
}
Uint64Set represents a set based on skip list.
func NewUint64 ¶
func NewUint64() *Uint64Set
NewUint64 returns an empty skip set in ascending order.
func (*Uint64Set) Add ¶ added in v0.8.0
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
type Uint64SetDesc ¶ added in v0.9.0
type Uint64SetDesc struct {
// contains filtered or unexported fields
}
Uint64SetDesc represents a set based on skip list.
func NewUint64Desc ¶ added in v0.9.0
func NewUint64Desc() *Uint64SetDesc
NewUint64Desc returns an empty skip set in descending order.
func (*Uint64SetDesc) Add ¶ added in v0.9.0
func (s *Uint64SetDesc) Add(value uint64) bool
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
func (*Uint64SetDesc) Contains ¶ added in v0.9.0
func (s *Uint64SetDesc) Contains(value uint64) bool
Contains checks if the value is in the skip set.
func (*Uint64SetDesc) Len ¶ added in v0.9.0
func (s *Uint64SetDesc) Len() int
Len returns the length of this skip set.
func (*Uint64SetDesc) Range ¶ added in v0.9.0
func (s *Uint64SetDesc) Range(f func(value uint64) bool)
Range calls f sequentially for each value present in the skip set. If f returns false, range stops the iteration.
func (*Uint64SetDesc) Remove ¶ added in v0.9.0
func (s *Uint64SetDesc) Remove(value uint64) bool
Remove removes a node from the skip set.
type UintSet ¶
type UintSet struct {
// contains filtered or unexported fields
}
UintSet represents a set based on skip list.
func (*UintSet) Add ¶ added in v0.8.0
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
type UintSetDesc ¶ added in v0.9.0
type UintSetDesc struct {
// contains filtered or unexported fields
}
UintSetDesc represents a set based on skip list.
func NewUintDesc ¶ added in v0.9.0
func NewUintDesc() *UintSetDesc
NewUintDesc returns an empty skip set in descending order.
func (*UintSetDesc) Add ¶ added in v0.9.0
func (s *UintSetDesc) Add(value uint) bool
Add adds the value into skip set, returns true if this process insert the value into skip set, returns false if this process can't insert this value, because another process has insert the same value.
If the value is in the skip set but not fully linked, this process will wait until it is.
func (*UintSetDesc) Contains ¶ added in v0.9.0
func (s *UintSetDesc) Contains(value uint) bool
Contains checks if the value is in the skip set.
func (*UintSetDesc) Len ¶ added in v0.9.0
func (s *UintSetDesc) Len() int
Len returns the length of this skip set.
func (*UintSetDesc) Range ¶ added in v0.9.0
func (s *UintSetDesc) Range(f func(value uint) bool)
Range calls f sequentially for each value present in the skip set. If f returns false, range stops the iteration.
func (*UintSetDesc) Remove ¶ added in v0.9.0
func (s *UintSetDesc) Remove(value uint) bool
Remove removes a node from the skip set.