maps

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package maps contains utility functions to manage maps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[K comparable, V any](m map[K]V, filter FilterType[K]) map[K]V

Filter filters a map, returning a duplicate which contains only the elements matching the filter function.

func Merge

func Merge[K comparable, V any](m1, m2 map[K]V) map[K]V

Merge merges two maps.

func Sub

func Sub[K comparable, V any](m1, m2 map[K]V) map[K]V

Sub removes elements of m2 from m1.

Types

type FilterType

type FilterType[K comparable] func(key K) bool

FilterType is a function type used to filter a map.

func FilterBlacklist

func FilterBlacklist[K comparable](blacklist ...K) FilterType[K]

FilterBlacklist returns a filter function returning true if the key is not the blacklist.

func FilterWhitelist

func FilterWhitelist[K comparable](whitelist ...K) FilterType[K]

FilterWhitelist returns a filter function returning true if the key is in the whitelist.

Jump to

Keyboard shortcuts

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