From 6c8b96ca28939a92ac3460e5b304c850667679a5 Mon Sep 17 00:00:00 2001 From: Anschel Schaffer-Cohen Date: Fri, 6 Aug 2010 16:39:18 -0700 Subject: exp/iterable: add UintArray all other basic types seem to be represented. R=rsc CC=golang-dev http://codereview.appspot.com/1919042 Committer: Russ Cox --- src/pkg/exp/iterable/array.go | 13 +++++++++++++ src/pkg/exp/iterable/iterable_test.go | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/src/pkg/exp/iterable/array.go b/src/pkg/exp/iterable/array.go index b5c7b5c6e..3ec799751 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 26a2eecc4..23151578c 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) -- cgit v1.2.1