added buffer argument to OfSeq and OfSeq2
This commit is contained in:
parent
29e60825bc
commit
e7c7fca697
8
of.go
8
of.go
@ -70,8 +70,8 @@ func OfMap[K comparable, V, T any](m map[K]V, unmapper func(K, V) T) <-chan T {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OfSeq returns a channel containing all values provided by the iterator
|
// OfSeq returns a channel containing all values provided by the iterator
|
||||||
func OfSeq[T any](seq iter.Seq[T]) <-chan T {
|
func OfSeq[T any](seq iter.Seq[T], buffer int) <-chan T {
|
||||||
out := make(chan T, 10)
|
out := make(chan T, buffer)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer close(out)
|
defer close(out)
|
||||||
@ -85,8 +85,8 @@ func OfSeq[T any](seq iter.Seq[T]) <-chan T {
|
|||||||
|
|
||||||
// OfSeq2 returns a channel containing the return values of the unmapper function
|
// OfSeq2 returns a channel containing the return values of the unmapper function
|
||||||
// when provided with the values of the iterator
|
// when provided with the values of the iterator
|
||||||
func OfSeq2[K comparable, V, T any](seq iter.Seq2[K, V], unmapper func(K, V) T) <-chan T {
|
func OfSeq2[K comparable, V, T any](seq iter.Seq2[K, V], buffer int, unmapper func(K, V) T) <-chan T {
|
||||||
out := make(chan T, 10)
|
out := make(chan T, buffer)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer close(out)
|
defer close(out)
|
||||||
|
Loading…
Reference in New Issue
Block a user