containers

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 2 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph added in v0.0.2

type Graph[K comparable] map[K][]K

func NewGraph added in v0.0.2

func NewGraph[K comparable]() Graph[K]

func (Graph[K]) AddEdge added in v0.0.2

func (g Graph[K]) AddEdge(from, to K)

func (Graph[K]) AddNode added in v0.0.2

func (g Graph[K]) AddNode(n K)

func (Graph[K]) Neighbors added in v0.0.2

func (g Graph[K]) Neighbors(from K) []K

func (Graph[K]) Nodes added in v0.0.2

func (g Graph[K]) Nodes() []K

type Queue

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

func NewQueue

func NewQueue[T any]() *Queue[T]

func (*Queue[T]) Empty

func (q *Queue[T]) Empty() bool

func (*Queue[T]) Len

func (q *Queue[T]) Len() int

func (*Queue[T]) Pop

func (q *Queue[T]) Pop() (res T, err error)

func (*Queue[T]) Push

func (q *Queue[T]) Push(val T)

type Set added in v0.0.3

type Set[V comparable] map[V]bool

func Intersect added in v0.0.4

func Intersect[V comparable](sets ...Set[V]) Set[V]

func NewSet added in v0.0.3

func NewSet[V comparable]() Set[V]

NewSet constructor to create new set Example: NewSet(int)() to create a int set NewSet(string)() to create a string set

func ToSet added in v0.0.3

func ToSet[V comparable](vals []V) Set[V]

ToSet method initializes new Set from slice Example: input := []string{"a", "b", "c"} newSet := ToSet[string](input)

func Union added in v0.0.4

func Union[V comparable](sets ...Set[V]) Set[V]

func (Set[V]) Add added in v0.0.3

func (s Set[V]) Add(v V)

Add values to set

func (Set[V]) Difference added in v0.0.4

func (s Set[V]) Difference(other Set[V]) Set[V]

Difference returns a set of objects that are not in s2 For example: s1 = {a1, a2, a3} s2 = {a1, a2, a4, a5} s1.Difference(s2) = {a3} s2.Difference(s1) = {a4, a5}

func (Set[V]) Equal added in v0.0.3

func (s Set[V]) Equal(other Set[V]) bool

Equal returns true if and only if original is equal (as a set) to other. Two sets are equal if their membership is identical. (In practice, this means same elements, order doesn't matter)

func (Set[V]) Has added in v0.0.3

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

Has checks if element exists in set

func (Set[V]) Intersect added in v0.0.4

func (s Set[V]) Intersect(other Set[V]) Set[V]

Intersect returns a new set which includes the item in BOTH s1 and s2 For example: s1 = {a1, a2} s2 = {a2, a3} s1.Intersect(s2) = {a2}

func (Set[V]) Len added in v0.0.3

func (s Set[V]) Len() int

Len return length of set

func (Set[V]) List added in v0.0.3

func (s Set[V]) List() []V

List returns the contents as a slice

func (Set[V]) Remove added in v0.0.3

func (s Set[V]) Remove(v V)

Remove deletes values from set

func (Set[V]) SymmetricDifference added in v0.0.4

func (s Set[V]) SymmetricDifference(other Set[V]) Set[V]

SymmetricDifference returns set of elements which are in either of the sets, but not in their intersection For example: s1 = {a1, a2, a3} s2 = {a3, a4} s1.SymmetricDifference(s2) = {a1, a2, a4}

func (Set[V]) Union added in v0.0.4

func (s Set[V]) Union(other Set[V]) Set[V]

Union returns a new set which includes items in either s1 or s2. For example: s1 = {a1, a2} s2 = {a3, a4} s1.Union(s2) = {a1, a2, a3, a4} s2.Union(s1) = {a1, a2, a3, a4}

type Stack

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

func NewStack

func NewStack[T any]() *Stack[T]

func (*Stack[T]) Empty

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

func (*Stack[T]) Len

func (stack *Stack[T]) Len() int

func (*Stack[T]) List added in v0.0.6

func (stack *Stack[T]) List() []T

func (*Stack[T]) Pop

func (stack *Stack[T]) Pop() (res T, err error)

func (*Stack[T]) Push

func (stack *Stack[T]) Push(value T)

Jump to

Keyboard shortcuts

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