-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//go:build go1.23 | ||
|
||
package history | ||
|
||
import ( | ||
"iter" | ||
"maps" | ||
) | ||
|
||
// All returns an iterator over key-value pairs in the map | ||
func (m Map[K, V]) All() iter.Seq2[K, V] { | ||
return maps.All(m.data) | ||
} | ||
|
||
// Keys returns an iterator over the map keys | ||
func (m Map[K, V]) Keys() iter.Seq[K] { | ||
return maps.Keys(m.data) | ||
} | ||
|
||
// Values returns an iterator over the map values | ||
func (m Map[K, V]) Values() iter.Seq[V] { | ||
return maps.Values(m.data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//go:build go1.23 | ||
|
||
package history | ||
|
||
import ( | ||
"iter" | ||
"maps" | ||
) | ||
|
||
// All returns an iterator over keys in the set | ||
func (s Set[K]) All() iter.Seq[K] { | ||
return maps.Keys(s.data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//go:build go1.23 | ||
|
||
package history | ||
|
||
import ( | ||
"iter" | ||
"slices" | ||
) | ||
|
||
// All returns an iterator over index-value pairs in the slice | ||
func (s Slice[T]) All() iter.Seq2[int, T] { | ||
return slices.All(s.data) | ||
} | ||
|
||
// Backward returns an iterator over index-value pairs in the slice, | ||
func (s Slice[T]) Backward() iter.Seq2[int, T] { | ||
return slices.Backward(s.data) | ||
} | ||
|
||
// Values returns an iterator that yields the slice elements in order. | ||
func (s Slice[T]) Values() iter.Seq[T] { | ||
return slices.Values(s.data) | ||
} |