Help us shape the future of Go! Take the 2026 Go Developer Survey

container

package
v1.20.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 5 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ImmSet added in v1.16.0

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

ImmSet is an immutable set optimized for a smallish (1-1000) set of items. Implemented as a sorted slice.

func NewImmSet added in v1.16.0

func NewImmSet[T cmp.Ordered](items ...T) ImmSet[T]

func NewImmSetFunc added in v1.16.0

func NewImmSetFunc[T any](compare func(T, T) int, items ...T) ImmSet[T]

func (ImmSet[T]) AsSlice added in v1.16.0

func (s ImmSet[T]) AsSlice() []T

AsSlice returns the underlying slice stored in the immutable set. The caller is NOT allowed to modify the slice.

func (ImmSet[T]) Delete added in v1.16.0

func (s ImmSet[T]) Delete(xs ...T) ImmSet[T]

func (ImmSet[T]) Difference added in v1.16.0

func (s ImmSet[T]) Difference(s2 ImmSet[T]) ImmSet[T]

func (ImmSet[T]) Equal added in v1.16.0

func (s ImmSet[T]) Equal(s2 ImmSet[T]) bool

func (ImmSet[T]) Has added in v1.16.0

func (s ImmSet[T]) Has(x T) bool

func (ImmSet[T]) Insert added in v1.16.0

func (s ImmSet[T]) Insert(xs ...T) ImmSet[T]

func (ImmSet[T]) Len added in v1.16.0

func (s ImmSet[T]) Len() int

func (*ImmSet[T]) MarshalJSON added in v1.17.0

func (s *ImmSet[T]) MarshalJSON() ([]byte, error)

func (ImmSet[T]) Union added in v1.16.0

func (s ImmSet[T]) Union(s2 ImmSet[T]) ImmSet[T]

func (*ImmSet[T]) UnmarshalJSON added in v1.17.0

func (s *ImmSet[T]) UnmarshalJSON(data []byte) error

type InsertOrderedMap added in v1.17.4

type InsertOrderedMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

InsertOrderedMap is a map that allows iterating over the keys in the order they were inserted.

func NewInsertOrderedMap added in v1.17.4

func NewInsertOrderedMap[K comparable, V any]() *InsertOrderedMap[K, V]

NewInsertOrderedMap creates a new insert-ordered map.

func (*InsertOrderedMap[K, V]) All added in v1.17.4

func (m *InsertOrderedMap[K, V]) All() iter.Seq2[K, V]

All returns an iterator for keys and values in the map in insertion order.

func (*InsertOrderedMap[K, V]) Clear added in v1.17.4

func (m *InsertOrderedMap[K, V]) Clear()

Clear the map.

func (*InsertOrderedMap[K, V]) Delete added in v1.17.4

func (m *InsertOrderedMap[K, V]) Delete(k K) (found bool)

Delete a key from the map. O(n).

func (*InsertOrderedMap[K, V]) Get added in v1.17.4

func (m *InsertOrderedMap[K, V]) Get(k K) (v V, found bool)

Get a value from the map. O(1).

func (*InsertOrderedMap[K, V]) Insert added in v1.17.4

func (m *InsertOrderedMap[K, V]) Insert(k K, v V)

Insert or update a key in the map. O(1). An update will not affect the ordering.

func (*InsertOrderedMap[K, V]) Keys added in v1.17.4

func (m *InsertOrderedMap[K, V]) Keys() iter.Seq[K]

Keys returns an iterator for the keys in the map in insertion order.

func (*InsertOrderedMap[K, V]) Len added in v1.17.4

func (m *InsertOrderedMap[K, V]) Len() int

Len returns the number of items in the map.

func (*InsertOrderedMap[K, V]) Values added in v1.17.4

func (m *InsertOrderedMap[K, V]) Values() iter.Seq[V]

Values returns an iterator for the values in the map in insertion order.

type RingBuffer added in v0.15.7

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

RingBuffer is a generic ring buffer implementation that contains sequential data (i.e. such as time ordered data). RingBuffer is implemented using slices. From testing, this should be fast than linked-list implementations, and also allows for efficient indexing of ordered data.

func NewRingBuffer added in v0.15.7

func NewRingBuffer[T any](bufferSize int) *RingBuffer[T]

NewRingBuffer constructs a new ring buffer for a given buffer size.

func (*RingBuffer[T]) Add added in v0.15.7

func (eb *RingBuffer[T]) Add(e T)

Add adds an element to the buffer.

func (*RingBuffer[T]) Compact added in v0.15.7

func (eb *RingBuffer[T]) Compact(isValid func(T) bool)

Compact clears out invalidated elements in the buffer. This may require copying the entire buffer. It is assumed that if buffer[i] is invalid then every entry [0...i-1] is also not valid.

func (*RingBuffer[T]) Iterate added in v0.15.7

func (eb *RingBuffer[T]) Iterate(callback func(T))

Iterate is a convenience function over IterateValid that iterates all elements in the buffer.

func (*RingBuffer[T]) IterateValid added in v0.15.7

func (eb *RingBuffer[T]) IterateValid(isValid func(T) bool, callback func(T))

IterateValid calls the callback on each element of the buffer, starting with the first element in the buffer that satisfies "isValid".

func (*RingBuffer[T]) Size added in v0.15.7

func (eb *RingBuffer[T]) Size() int

Size returns the size of the buffer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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