container

package
v0.50.5 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container[T any] interface {
	// Add consumes an item
	Add(item T) bool

	// Full return true if container is full
	Full() bool

	// returns items as slice
	Items() []T
}

Container is a collection of items More functions like remove can be added if future use cases arise

func NewBounded

func NewBounded[T any](capacity int) (Container[T], error)

NewBounded returns a container of type bounded. Bounded is a container with limited capacity and stops consuming more elements once capacity is reached.

func NewFIFO

func NewFIFO[T any](capacity int, cleanupfn func(T)) (Container[T], error)

NewFIFO returns a container of type fifo. fifo is a container with limited capacity which keeps last 'N' inserted elements upto capacity. Additionally in order to do any cleanup on removed elements a cleanup function can be passed as well.

func NewUnbounded

func NewUnbounded[T any]() (Container[T], error)

NewUnbounded returns a container of type unbounded. unbounded is a container with unlimited capacity.

Jump to

Keyboard shortcuts

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