Source File
iter.go
Belonging Package
maps
// Copyright 2024 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
import
// All returns an iterator over key-value pairs from m.
// The iteration order is not specified and is not guaranteed
// to be the same from one call to the next.
func [ ~map[], comparable, any]( ) iter.Seq2[, ] {
return func( func(, ) bool) {
for , := range {
if !(, ) {
return
}
}
}
}
// Keys returns an iterator over keys in m.
// The iteration order is not specified and is not guaranteed
// to be the same from one call to the next.
func [ ~map[], comparable, any]( ) iter.Seq[] {
return func( func() bool) {
for := range {
if !() {
return
}
}
}
}
// Values returns an iterator over values in m.
// The iteration order is not specified and is not guaranteed
// to be the same from one call to the next.
func [ ~map[], comparable, any]( ) iter.Seq[] {
return func( func() bool) {
for , := range {
if !() {
return
}
}
}
}
// Insert adds the key-value pairs from seq to m.
// If a key in seq already exists in m, its value will be overwritten.
func [ ~map[], comparable, any]( , iter.Seq2[, ]) {
for , := range {
[] =
}
}
// Collect collects key-value pairs from seq into a new map
// and returns it.
func [ comparable, any]( iter.Seq2[, ]) map[] {
:= make(map[])
Insert(, )
return
}
The pages are generated with Golds v0.7.6. (GOOS=linux GOARCH=amd64)