Documentation ¶
Overview ¶
Package poolslice supports allocating slots out of a slice.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IndexGenerator ¶
type IndexGenerator struct {
// contains filtered or unexported fields
}
An IndexGenerator allocates slice indexes, allowing re-use. This lets you insert remove items within a slice dynamically, re-using empty slots when available.
func (*IndexGenerator) Alloc ¶
func (g *IndexGenerator) Alloc() int
Alloc allocates a free index. Will use an empty slot if available.
func (*IndexGenerator) Release ¶
func (g *IndexGenerator) Release(index int)
Release marks an index as free.
type PoolSlice ¶
type PoolSlice[T any] struct { Items []T // The slice // contains filtered or unexported fields }
A PoolSlice wraps a slice, adding support for tracking free vs. in-use slots and inserting new elements into free slots.
Click to show internal directories.
Click to hide internal directories.