keyedstack

package
v0.0.0-...-36085eb Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyedStack

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

KeyedStack is a last-in-first-out container where entries are unique per key This container is goroutine-safe

func New

func New[K comparable, V any](baseValue V) *KeyedStack[K, V]

New returns a new KeyedStack with the specified base/default value

func (*KeyedStack[K, V]) Get

func (s *KeyedStack[K, V]) Get() V

Get returns the current value at the top of the stack

func (*KeyedStack[K, V]) GetAll

func (s *KeyedStack[K, V]) GetAll(includeDefaultValue bool) []V

GetAll returns the complete stack values

func (*KeyedStack[K, V]) GetAllOfKey

func (s *KeyedStack[K, V]) GetAllOfKey(key K) []V

GetAllOfKey returns all values for the specified key

func (*KeyedStack[K, V]) GetOfKey

func (s *KeyedStack[K, V]) GetOfKey(key K) V

GetOfKey returns the topmost value for the specified key

func (*KeyedStack[K, V]) Len

func (s *KeyedStack[K, V]) Len() int

Len returns the number of items in the stack

func (*KeyedStack[K, V]) OnValueUpdated

func (s *KeyedStack[K, V]) OnValueUpdated() event.Event[V]

OnValueUpdated returns the event that is fired when the value at the top of the stack is updated

func (*KeyedStack[K, V]) Push

func (s *KeyedStack[K, V]) Push(key K, value V) (V, bool)

Push updates the current value, replacing any value that the provided key has already set Returns true and the previous value for the key, if the value was replaced

func (*KeyedStack[K, V]) Remove

func (s *KeyedStack[K, V]) Remove(key K) (V, bool)

Remove removes a value by key. Returns true and the previous value for the key, if the value was present

Jump to

Keyboard shortcuts

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