// 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 (_)// Equal reports whether two maps contain the same key/value pairs.// Values are compared using ==.func [, ~map[], , comparable]( , ) bool {iflen() != len() {returnfalse }for , := range {if , := []; ! || != {returnfalse } }returntrue}// EqualFunc is like Equal, but compares values using eq.// Keys are still compared with ==.func [ ~map[], ~map[], comparable, , any]( , , func(, ) bool) bool {iflen() != len() {returnfalse }for , := range {if , := []; ! || !(, ) {returnfalse } }returntrue}// clone is implemented in the runtime package.////go:linkname clone maps.clonefunc clone( any) any// Clone returns a copy of m. This is a shallow clone:// the new keys and values are set using ordinary assignment.func [ ~map[], comparable, any]( ) {// Preserve nil in case it matters.if == nil {returnnil }returnclone().()}// 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.func [ ~map[], ~map[], comparable, any]( , ) {for , := range { [] = }}// DeleteFunc deletes any key/value pairs from m for which del returns true.func [ ~map[], comparable, any]( , func(, ) bool) {for , := range {if (, ) {delete(, ) } }}
The pages are generated with Goldsv0.7.0-preview. (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.