mirror of
https://github.com/opentofu/opentofu.git
synced 2026-02-18 18:17:54 -05:00
addrs: Set.All for iterating the set elements
Since an addrs.Set is really just a map with some special usage rules, this is just a thin wrapper around maps.Values but (as with many of the other methods on this type) avoids exposing that implementation detail in calling code. Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
This commit is contained in:
parent
08ba66ab6e
commit
6760b02f65
1 changed files with 6 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ package addrs
|
|||
|
||||
import (
|
||||
"iter"
|
||||
"maps"
|
||||
)
|
||||
|
||||
// Set represents a set of addresses of types that implement UniqueKeyer.
|
||||
|
|
@ -42,6 +43,11 @@ func (s Set[T]) Has(addr T) bool {
|
|||
return exists
|
||||
}
|
||||
|
||||
// All returns a sequence of all addresses in the set in a pseudorandom order.
|
||||
func (s Set[T]) All() iter.Seq[T] {
|
||||
return maps.Values(s)
|
||||
}
|
||||
|
||||
// Add inserts the given address into the set, if not already present. If
|
||||
// an equivalent address is already in the set, this replaces that address
|
||||
// with the new value.
|
||||
|
|
|
|||
Loading…
Reference in a new issue