utils

package
v0.0.0-...-8b11df5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeFilledMap

func MakeFilledMap[T any](size int, defaultValue T) map[int]T

func MultiplyArray

func MultiplyArray[T Number](numbers []T) T

func ProcessFile

func ProcessFile[T any](path string, textHandler textHandler[T]) []T

func ReadFile

func ReadFile(path string) []string

func RemoveEmptyStrings

func RemoveEmptyStrings(strings []string) []string

func SumArray

func SumArray[T Number](numbers []T) T

func SumMapValues

func SumMapValues[TKey comparable, TValue Number](mapToSum map[TKey]TValue) TValue

func WriteToFile

func WriteToFile(path string, content string)

Types

type FilterFunc

type FilterFunc[T comparable] func(v T) bool

type Number

type Number interface {
	constraints.Integer | constraints.Float
}

type Set

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

func NewSet

func NewSet[T comparable]() *Set[T]

func (*Set[T]) Add

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

func (*Set[T]) AddMulti

func (s *Set[T]) AddMulti(list ...T)

AddMulti Add multiple values in the set

func (*Set[T]) Clear

func (s *Set[T]) Clear()

func (*Set[T]) Difference

func (s *Set[T]) Difference(s2 *Set[T]) *Set[T]

Difference returns the subset from s, that doesn't exists in s2 (param)

func (*Set[T]) Filter

func (s *Set[T]) Filter(P FilterFunc[T]) *Set[T]

Filter returns a subset, that contains only the values that satisfies the given predicate P

func (*Set[T]) Has

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

func (*Set[T]) Intersect

func (s *Set[T]) Intersect(s2 *Set[T]) *Set[T]

func (*Set[T]) Remove

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

func (*Set[T]) Size

func (s *Set[T]) Size() int

func (*Set[T]) Union

func (s *Set[T]) Union(s2 *Set[T]) *Set[T]

Jump to

Keyboard shortcuts

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