diff options
author | Anschel Schaffer-Cohen <anschelsc@gmail.com> | 2010-08-06 16:39:18 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-08-06 16:39:18 -0700 |
commit | 8055f4702952d5b4cc59dc0a8c56aec1a3092268 (patch) | |
tree | 74162be8f4344e4dd6292d9e6f1b0ea525c84232 | |
parent | 8c5f30c0d94cf657b7c7e9329ac8c87b515a8869 (diff) | |
download | go-8055f4702952d5b4cc59dc0a8c56aec1a3092268.tar.gz go-8055f4702952d5b4cc59dc0a8c56aec1a3092268.zip |
exp/iterable: add UintArray
all other basic types seem to be represented.
R=rsc
CC=golang-dev
https://golang.org/cl/1919042
-rw-r--r-- | src/pkg/exp/iterable/array.go | 13 | ||||
-rw-r--r-- | src/pkg/exp/iterable/iterable_test.go | 4 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/pkg/exp/iterable/array.go b/src/pkg/exp/iterable/array.go index b5c7b5c6ea..3ec7997512 100644 --- a/src/pkg/exp/iterable/array.go +++ b/src/pkg/exp/iterable/array.go @@ -57,3 +57,16 @@ func (a StringArray) Iter() <-chan interface{} { }() return ch } + +type UintArray []uint + +func (a UintArray) Iter() <-chan interface{} { + ch := make(chan interface{}) + go func() { + for _, e := range a { + ch <- e + } + close(ch) + }() + return ch +} diff --git a/src/pkg/exp/iterable/iterable_test.go b/src/pkg/exp/iterable/iterable_test.go index 26a2eecc45..23151578c1 100644 --- a/src/pkg/exp/iterable/iterable_test.go +++ b/src/pkg/exp/iterable/iterable_test.go @@ -15,6 +15,10 @@ func TestArrayTypes(t *testing.T) { if x := Data(bytes)[1].(byte); x != 2 { t.Error("Data(bytes)[1].(byte) = %v, want 2", x) } + uints := UintArray([]uint{1, 2, 3}) + if x := Data(uints)[1].(uint); x != 2 { + t.Error("Data(uints)[1].(uint) = %v, want 2", x) + } ints := IntArray([]int{1, 2, 3}) if x := Data(ints)[2].(int); x != 3 { t.Error("Data(ints)[2].(int) = %v, want 3", x) |