slicesutil

package
v1.132.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: Apache-2.0 Imports: 1 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtendCapacity

func ExtendCapacity[T any](a []T, itemsToAdd int) []T

ExtendCapacity returns a with the capacity extended to len(a)+itemsToAdd.

It may allocate new slice if cap(a) is smaller than len(a)+itemsToAdd.

func SetLength

func SetLength[T any](a []T, newLen int) []T

SetLength sets len(a) to newLen and returns the result.

It may allocate new slice if cap(a) is smaller than newLen.

Types

type Buffer added in v1.110.22

type Buffer[T any] struct {
	// B is the underlying T slice.
	B []T
}

Buffer implements a simple buffer for T.

func (*Buffer[T]) Reset added in v1.110.22

func (b *Buffer[T]) Reset()

Reset resets b.

type BufferPool added in v1.110.22

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

BufferPool is a pool of T Buffers.

func (*BufferPool[T]) Get added in v1.110.22

func (bp *BufferPool[T]) Get() *Buffer[T]

Get obtains a Buffer from bp.

func (*BufferPool[T]) Put added in v1.110.22

func (bp *BufferPool[T]) Put(b *Buffer[T])

Put puts b into bp.

Jump to

Keyboard shortcuts

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