datastruct

package
v0.296.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapAdd

func MapAdd[K comparable, V any, Map MapInterface[K, V]](m Map, k K, v V) func()

Types

type Map

type Map[K comparable, V any] map[K]V

func (Map[K, V]) Delete

func (m Map[K, V]) Delete(key K)

func (Map[K, V]) Get

func (m Map[K, V]) Get(key K) V

func (Map[K, V]) Keys

func (m Map[K, V]) Keys() []K

func (Map[K, V]) Len

func (m Map[K, V]) Len() int

func (Map[K, V]) Lookup

func (m Map[K, V]) Lookup(key K) (V, bool)

func (Map[K, V]) Set

func (m Map[K, V]) Set(key K, val V)

type MapInterface

type MapInterface[K comparable, V any] interface {
	Lookup(key K) (V, bool)
	Get(key K) V
	Set(key K, val V)
	Delete(key K)

	Len() int
	Keys() []K
}

type Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

func (*Set[T]) Add

func (s *Set[T]) Add(v T)

func (Set[T]) From added in v0.296.0

func (set Set[T]) From(vs ...T) Set[T]

func (Set[T]) FromSlice added in v0.296.0

func (set Set[T]) FromSlice(vs []T) Set[T]

func (Set[T]) Has

func (s Set[T]) Has(v T) bool

func (Set[T]) ToSlice

func (s Set[T]) ToSlice() []T

type Stack

type Stack[T any] []T

func (*Stack[T]) IsEmpty

func (s *Stack[T]) IsEmpty() bool

IsEmpty check if stack is empty

func (*Stack[T]) Last

func (s *Stack[T]) Last() (T, bool)

Last returns the last stack element

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() (T, bool)

Pop remove and return top element of stack. Return false if stack is empty.

func (*Stack[T]) Push

func (s *Stack[T]) Push(v T)

Push a new value onto the stack

Jump to

Keyboard shortcuts

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