Documentation
¶
Overview ¶
Example (Bitmap64AndWrappedEmpty) ¶
package main
import (
"fmt"
"github.com/specterops/dawgs/cardinality"
)
func main() {
bitmap := cardinality.NewBitmap64With(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
bitmap.And(cardinality.ThreadSafeDuplex(cardinality.NewBitmap64With(2, 4, 6)))
fmt.Println(bitmap.Slice())
}
Output: [2 4 6]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommutativeDuplexes ¶ added in v0.4.8
func (*CommutativeDuplexes[T]) And ¶ added in v0.4.8
func (s *CommutativeDuplexes[T]) And(dc DuplexCommutation[T])
func (*CommutativeDuplexes[T]) Contains ¶ added in v0.4.8
func (s *CommutativeDuplexes[T]) Contains(value T) bool
func (*CommutativeDuplexes[T]) Or ¶ added in v0.4.8
func (s *CommutativeDuplexes[T]) Or(dc DuplexCommutation[T])
type Duplex ¶
type Duplex[T uint32 | uint64] interface { Provider[T] Xor(other Provider[T]) And(other Provider[T]) AndNot(other Provider[T]) Remove(value T) Slice() []T Contains(value T) bool Each(delegate func(value T) bool) CheckedAdd(value T) bool Clone() Duplex[T] }
Duplex is a two-way cardinality provider that allows a user to retrieve encoded values back out of the provider. This interface is suitable for algorithms that behave similar to bitvectors.
func NewBitmap32 ¶
func NewBitmap32With ¶
func NewBitmap64 ¶
func NewBitmap64With ¶
func ThreadSafeDuplex ¶
ThreadSafeDuplex synchronizes all operations of the wrapped Duplex with a single lock. Binary operations (Or, And, Xor, AndNot) snapshot another thread-safe wrapper before acquiring the receiver's lock, so opposing cross-wrapper operations and self-operations cannot form a lock-order cycle. Each operation is atomic for its receiver; there is no cross-operand atomicity, and a snapshot reflects the other wrapper only at the moment it was taken. Delegates passed to Each must not call back into the same wrapper.
type DuplexCommutation ¶ added in v0.4.8
func CommutativeOr ¶ added in v0.4.8
func CommutativeOr[T uint32 | uint64](duplexes ...Duplex[T]) DuplexCommutation[T]
func (DuplexCommutation[T]) Contains ¶ added in v0.4.8
func (s DuplexCommutation[T]) Contains(value T) bool
func (DuplexCommutation[T]) Or ¶ added in v0.4.8
func (s DuplexCommutation[T]) Or(duplexes ...Duplex[T]) DuplexCommutation[T]
type DuplexConstructor ¶
type Iterator ¶
Iterator allows enumeration of a duplex cardinality provider without requiring the allocation of the provider's set.
type Provider ¶
type Provider[T uint32 | uint64] interface { Add(value ...T) Or(other Provider[T]) Clear() Cardinality() uint64 }
Provider describes the most basic functionality of a cardinality provider algorithm: adding elements to the provider and producing the cardinality of those elements.
func NewBitmap32Provider ¶
func NewBitmap64Provider ¶
type ProviderConstructor ¶
type Simplex ¶
Simplex is a one-way cardinality provider that does not allow a user to retrieve encoded values back out of the provider. This interface is suitable for algorithms such as HyperLogLog which utilizes a hash function to merge identifiers into the cardinality provider.
func NewHyperLogLog32 ¶
func NewHyperLogLog64 ¶
func ThreadSafeSimplex ¶
ThreadSafeSimplex synchronizes all operations of the wrapped Simplex with a single lock. Or snapshots another thread-safe wrapper before acquiring the receiver's lock, so cross-wrapper merges cannot form a lock-order cycle and merge with a wrapped sketch reaches its implementation instead of being silently dropped by provider dispatch. There is no cross-operand atomicity.