// 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 maps import ( _ ) // Equal reports whether two maps contain the same key/value pairs. // Values are compared using ==. func [, ~map[], , comparable]( , ) bool { if len() != len() { return false } for , := range { if , := []; ! || != { return false } } return true } // EqualFunc is like Equal, but compares values using eq. // Keys are still compared with ==. func [ ~map[], ~map[], comparable, , any]( , , func(, ) bool) bool { if len() != len() { return false } for , := range { if , := []; ! || !(, ) { return false } } return true } // clone is implemented in the runtime package. // //go:linkname clone maps.clone func 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 { return nil } return 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. 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(, ) } } }