aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam/orderedmapsimp.dir/a.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/typeparam/orderedmapsimp.dir/a.go')
-rw-r--r--test/typeparam/orderedmapsimp.dir/a.go38
1 files changed, 19 insertions, 19 deletions
diff --git a/test/typeparam/orderedmapsimp.dir/a.go b/test/typeparam/orderedmapsimp.dir/a.go
index 1b5827b4bb..37fc3e79b9 100644
--- a/test/typeparam/orderedmapsimp.dir/a.go
+++ b/test/typeparam/orderedmapsimp.dir/a.go
@@ -100,25 +100,25 @@ type keyValue[K, V any] struct {
}
// iterate returns an iterator that traverses the map.
-// func (m *Map[K, V]) Iterate() *Iterator[K, V] {
-// sender, receiver := Ranger[keyValue[K, V]]()
-// var f func(*node[K, V]) bool
-// f = func(n *node[K, V]) bool {
-// if n == nil {
-// return true
-// }
-// // Stop the traversal if Send fails, which means that
-// // nothing is listening to the receiver.
-// return f(n.left) &&
-// sender.Send(context.Background(), keyValue[K, V]{n.key, n.val}) &&
-// f(n.right)
-// }
-// go func() {
-// f(m.root)
-// sender.Close()
-// }()
-// return &Iterator[K, V]{receiver}
-// }
+func (m *Map[K, V]) Iterate() *Iterator[K, V] {
+ sender, receiver := Ranger[keyValue[K, V]]()
+ var f func(*node[K, V]) bool
+ f = func(n *node[K, V]) bool {
+ if n == nil {
+ return true
+ }
+ // Stop the traversal if Send fails, which means that
+ // nothing is listening to the receiver.
+ return f(n.left) &&
+ sender.Send(context.Background(), keyValue[K, V]{n.key, n.val}) &&
+ f(n.right)
+ }
+ go func() {
+ f(m.root)
+ sender.Close()
+ }()
+ return &Iterator[K, V]{receiver}
+}
// Iterator is used to iterate over the map.
type Iterator[K, V any] struct {