algorithms

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2022 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count[T comparable](data []T, value T) int

Counts all occurrences of the given value in the given slice.

func CountIf

func CountIf[T comparable](data []T, predicate func(value T) bool) int

Counts all occurrences of values satisfying the given predicate in the given slice.

func Fill added in v0.2.0

func Fill[T any](data []T, value T)

Fills the given slice with the given value

func Find

func Find[T comparable](data []T, value T) bool

Finds the given value in the given slice, returns true if it is found. Returns false if nothing found or the slice is empty.

func FindIf

func FindIf[T any](data []T, defaultValue T, predicate func(value T) bool) T

Finds a value satisfying the given predicate in the given slice and returns it. Returns defaultValue if nothing found or the slice is empty.

func Max added in v0.1.7

func Max[T constraints.Ordered](first, second T) T

Returns the maxmimum of two values

func MaxElement

func MaxElement[T constraints.Ordered](data []T, defaultValue T) T

Finds a maximal value in the given slice and returns it. Returns defaultValue if the slice is empty

func Min added in v0.1.7

func Min[T constraints.Ordered](first, second T) T

Returns the minimum of two values

func MinElement

func MinElement[T constraints.Ordered](data []T, defaultValue T) T

Finds a minimal value in the given slice and returns it. Returns defaultValue if the slice is empty

Types

This section is empty.

Jump to

Keyboard shortcuts

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