pool

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package pool provides pools for scratch slices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Slice

type Slice[T any] struct {
	// contains filtered or unexported fields
}

Slice is a pool of slices with element type T. The zero value is ready to use.

var (
	Ints    Slice[int]    // Pool for []int.
	Uint64s Slice[uint64] // Pool for []uint64.
	Bytes   Slice[byte]   // Pool for []byte.
)

func (*Slice[T]) Get

func (s *Slice[T]) Get(n int) []T

Get returns a slice of length n with all elements set to the zero value of T.

func (*Slice[T]) GetUncleared

func (s *Slice[T]) GetUncleared(n int) []T

GetUncleared returns a slice of length n. Its elements have unspecified values.

func (*Slice[T]) Put

func (s *Slice[T]) Put(v []T)

Put adds v to the pool. The caller must not use v after Put.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL