Source File
maps.go
Belonging Package
golang.org/x/exp/maps
// Copyright 2021 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.// Package maps defines various functions useful with maps of any type.package mapsimport// Keys returns the keys of the map m.// The keys will be in an indeterminate order.//// The simplest true equivalent using the standard library is://// slices.AppendSeq(make([]K, 0, len(m)), maps.Keys(m))func [ ~map[], comparable, any]( ) [] {:= make([], 0, len())for := range {= append(, )}return}// Values returns the values of the map m.// The values will be in an indeterminate order.//// The simplest true equivalent using the standard library is://// slices.AppendSeq(make([]V, 0, len(m)), maps.Values(m))func [ ~map[], comparable, any]( ) [] {:= make([], 0, len())for , := range {= append(, )}return}// Equal reports whether two maps contain the same key/value pairs.// Values are compared using ==.////go:fix inlinefunc [, ~map[], , comparable]( , ) bool {return maps.Equal(, )}// EqualFunc is like Equal, but compares values using eq.// Keys are still compared with ==.////go:fix inlinefunc [ ~map[], ~map[], comparable, , any]( , , func(, ) bool) bool {return maps.EqualFunc(, , )}// Clear removes all entries from m, leaving it empty.////go:fix inlinefunc [ ~map[], comparable, any]( ) {clear()}// Clone returns a copy of m. This is a shallow clone:// the new keys and values are set using ordinary assignment.////go:fix inlinefunc [ ~map[], comparable, any]( ) {return maps.Clone()}// Copy copies all key/value pairs in src adding them to dst.// When a key in src is already present in dst,// the value in dst will be overwritten by the value associated// with the key in src.////go:fix inlinefunc [ ~map[], ~map[], comparable, any]( , ) {maps.Copy(, )}// DeleteFunc deletes any key/value pairs from m for which del returns true.////go:fix inlinefunc [ ~map[], comparable, any]( , func(, ) bool) {maps.DeleteFunc(, )}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |