Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllocateTargets ¶
func AllocateTargets[K comparable](groups []AllocationGroup[K], maxTotal int) map[K]int
AllocateTargets splits maxTotal across groups proportionally to their lengths, using largest-remainder rounding so the allocation sums exactly to maxTotal (or to the sum of group lengths, whichever is smaller). A negative maxTotal means "unlimited": every group keeps its full length.
func SampleEvenly ¶
SampleEvenly returns k elements of in, spaced as evenly as possible across its full span (always including the first and last element when k >= 2). It returns in unchanged when k >= len(in), and an empty slice when k <= 0.
Types ¶
type AllocationGroup ¶
type AllocationGroup[K comparable] struct { Key K Length int }
AllocationGroup is one group of records competing for a share of a fixed total point budget in AllocateTargets.
Click to show internal directories.
Click to hide internal directories.