Documentation ¶
Index ¶
- type Bag
- func (b *Bag[T]) Add(elts ...T)
- func (b *Bag[T]) AddCount(elt T, count int)
- func (b *Bag[T]) Count(elt T) int
- func (b *Bag[T]) Equals(other Bag[T]) bool
- func (b *Bag[T]) Filter(filterFunc func(T) bool) Bag[T]
- func (b *Bag[_]) Len() int
- func (b *Bag[T]) List() []T
- func (b *Bag[T]) Mode() (T, int)
- func (b *Bag[_]) PrefixedString(prefix string) string
- func (b *Bag[T]) Remove(elt T)
- func (b *Bag[_]) SetThreshold(threshold int)
- func (b *Bag[T]) Split(splitFunc func(T) bool) [2]Bag[T]
- func (b *Bag[_]) String() string
- func (b *Bag[T]) Threshold() set.Set[T]
- type UniqueBag
- func (b *UniqueBag[T]) Add(n uint, keys ...T)
- func (b *UniqueBag[T]) Bag(threshold int) Bag[T]
- func (b *UniqueBag[_]) Clear()
- func (b *UniqueBag[T]) Difference(diff *UniqueBag[T])
- func (b *UniqueBag[T]) DifferenceSet(key T, set set.Bits64)
- func (b *UniqueBag[T]) GetSet(key T) set.Bits64
- func (b *UniqueBag[T]) List() []T
- func (b *UniqueBag[_]) PrefixedString(prefix string) string
- func (b *UniqueBag[T]) RemoveSet(key T)
- func (b *UniqueBag[_]) String() string
- func (b *UniqueBag[T]) UnionSet(key T, set set.Bits64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bag ¶
type Bag[T comparable] struct { // contains filtered or unexported fields }
Bag is a multiset.
func (*Bag[T]) Add ¶
func (b *Bag[T]) Add(elts ...T)
Add increases the number of times each element has been seen by one.
func (*Bag[T]) AddCount ¶
AddCount increases the number of times the element has been seen by [count]. If [count] <= 0 this is a no-op.
func (*Bag[T]) Filter ¶
Returns a bag with the elements of this bag that return true for [filterFunc], along with their counts. For example, if X is in this bag with count 5, and filterFunc(X) returns true, then the returned bag contains X with count 5.
func (*Bag[T]) List ¶
func (b *Bag[T]) List() []T
List returns a list of unique elements that have been added. The returned list doesn't have duplicates.
func (*Bag[T]) Mode ¶
Mode returns the most common element in the bag and the count of that element. If there's a tie, any of the tied element may be returned. TODO for Stephen: Does the above violate an assumption made by Snowball? If the bag is empty, the zero value and 0 are returned.
func (*Bag[_]) PrefixedString ¶
func (*Bag[_]) SetThreshold ¶
SetThreshold sets the number of times an element must be added to be contained in the threshold set.
func (*Bag[T]) Split ¶
Returns: 1. A bag containing the elements of this bag that return false for [splitFunc]. 2. A bag containing the elements of this bag that return true for [splitFunc]. Counts are preserved in the returned bags. For example, if X is in this bag with count 5, and splitFunc(X) is false, then the first returned bag has X in it with count 5.
type UniqueBag ¶
type UniqueBag[T comparable] map[T]set.Bits64
Maps a key to a bitset.
func (*UniqueBag[T]) Bag ¶
Returns a bag with the given [threshold] where each key is in the bag once for each element in the key's bitset.
func (*UniqueBag[T]) Difference ¶
For each key/bitset pair in [diff], removes each element of the bitset from the bitset associated with the key in [b]. Keys in [diff] that are not in [b] are ignored. Bitset elements in [diff] that are not in the bitset associated with the key in [b] are ignored.
func (*UniqueBag[T]) DifferenceSet ¶
Removes each element of set from the bitset associated with [key].