container

package
v1.18.5 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 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 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(bufferSize int) *RingBuffer

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

func (*RingBuffer) Add added in v0.15.7

func (eb *RingBuffer) Add(e any)

Add adds an element to the buffer.

func (*RingBuffer) Compact added in v0.15.7

func (eb *RingBuffer) Compact(isValid func(any) 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) Iterate added in v0.15.7

func (eb *RingBuffer) Iterate(callback func(any))

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

func (*RingBuffer) IterateValid added in v0.15.7

func (eb *RingBuffer) IterateValid(isValid func(any) bool, callback func(any))

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

func (*RingBuffer) Size added in v0.15.7

func (eb *RingBuffer) 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