Documentation
¶
Overview ¶
Package reuse provides operations on reusable scratch storage.
Index ¶
Constants ¶
const RetentionFrames = 30
Variables ¶
This section is empty.
Functions ¶
func Reset ¶
Reset clears references throughout the backing array and keeps bounded scratch storage. Oversized arrays are released instead of retained in a pool.
func Resize ¶
Resize reuses storage when capacity permits. Growth starts with zeroed values; callers fill the result rather than relying on old contents after growth.
func UpdateAt ¶
func UpdateAt[T comparable](values *[]T, index int, value T) bool
UpdateAt appends or replaces the next observed value and reports a change. Callers visit indices in order and truncate the slice after the last value.
Types ¶
type MapRetention ¶
type MapRetention struct {
// contains filtered or unexported fields
}
MapRetention tracks the largest live population because Go maps expose no capacity. Rebuilding after sustained underuse releases historical buckets.
func (*MapRetention) Record ¶
func (r *MapRetention) Record(length int)
func (*MapRetention) Trim ¶
func (r *MapRetention) Trim[K comparable, V any](values map[K]V, minimum int) map[K]V
type Retention ¶
type Retention struct {
// contains filtered or unexported fields
}
Retention releases historical peaks after sustained underuse. Record folds multiple batches into one observation; Trim observes once per completed frame.
func (*Retention) Trim ¶
Trim preserves live values and keeps twice the recent peak, with a small capacity floor. Empty, unused storage is released entirely.
func (*Retention) TrimCapacity ¶
TrimCapacity returns zero while storage stays warm, -1 when idle storage can be released, or a smaller capacity after sustained underuse.