maps

package
v1.2.58 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: MIT Imports: 0 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Set added in v1.2.26

func Set[M map[K]struct{}, K comparable](ks ...K) (m M)

Set implements a non-thread safe Set

func Split added in v1.2.40

func Split[M ~map[K]V, K comparable, V any](m M, sep int) []M

Split slices s into all submaps separated by sep and returns a slice of the submaps between those separators.

If s is less than sep and sep is more than zero, Split returns a slice of length 1 whose only element is s.

If s is nil, Split returns nil (zero submaps).

If both s and sep are empty or zero, Split returns an empty slice.

If sep is <= zero, Split splits after each element, as chunk size is 1.

It is equivalent to SplitN with a count of -1.

func SplitN

func SplitN[M ~map[K]V, K comparable, V any](m M, sep int, n int) []M

SplitN slices s into submaps and returns a slice of the submaps.

The count determines the number of submaps to return:

  n > 0: at most n submaps; the last submaps will be the unsplit remainder.
		The count determines the number of submaps to return:
  		sep > 0: Split splits every sep as chunk size; the last submaps will be the unsplit remainder.
  		sep <= 0: take len(S)/n as chunk size
  n == 0: the result is nil (zero submaps)
  n < 0: all submaps as n == len(s)

Edge cases for s and sep (for example, zero) are handled as described in the documentation for Split.

Types

This section is empty.

Jump to

Keyboard shortcuts

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