Documentation ¶
Index ¶
- func KeepIfBuckets[T any](buckets map[int]*Bucket[T], f slext.PredicateFilter[T]) map[int]*Bucket[T]
- func MakeBuckets[T any](elems []T, f func(T) int) map[int]*Bucket[T]
- func SortBuckets[T any](buckets map[int]*Bucket[T], f SortFunc[T])
- func ViewTopNBuckets[T any](buckets map[int]*Bucket[T], n int) map[int]*Bucket[T]
- type Bucket
- type SortFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KeepIfBuckets ¶
func KeepIfBuckets[T any](buckets map[int]*Bucket[T], f slext.PredicateFilter[T]) map[int]*Bucket[T]
KeepIfBuckets keeps the elements in the buckets that satisfy the given predicate filter.
Parameters:
- buckets: buckets to filter.
- f: predicate filter to use.
Returns:
- map[int]*Bucket: the filtered buckets.
func MakeBuckets ¶
MakeBuckets creates a map of buckets from the given elements using the given function.
Parameters:
- elems: elements to add to the buckets.
- f: function to use to determine the size of the buckets.
Returns:
- map[int]*Bucket: the map of buckets.
func SortBuckets ¶
SortBuckets sorts the buckets using the given function.
Parameters:
- buckets: buckets to sort.
- f: comparison function to use.
Types ¶
type Bucket ¶
type Bucket[T any] struct { // contains filtered or unexported fields }
Bucket represents a bucket of elements.
func NewBucket ¶
NewBucket creates a new bucket of elements.
Parameters:
- elements: elements to add to the bucket.
Returns:
- *Bucket: the new bucket.
func (*Bucket[T]) Add ¶
func (b *Bucket[T]) Add(element T)
Add adds a element to the bucket.
Parameters:
- element: element to add.
func (*Bucket[T]) GetSize ¶
GetSize returns the size of the bucket.
Returns:
- int: the size of the bucket.
func (*Bucket[T]) InsertionSort ¶
InsertionSort sorts the elements in the bucket using the given comparison function.
Parameters:
- f: comparison function to use.
func (*Bucket[T]) Limit ¶
Limit limits the number of elements in the bucket.
Parameters:
- n: number of elements to keep.
Returns:
- *Bucket: the bucket.
func (*Bucket[T]) LinearKeep ¶
func (b *Bucket[T]) LinearKeep(f us.PredicateFilter[T])
LinearKeep keeps the elements in the bucket that satisfy the given predicate filter.
Parameters:
- f: predicate filter to use.