summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnschel Schaffer-Cohen <anschelsc@gmail.com>2010-08-06 16:39:18 -0700
committerAnschel Schaffer-Cohen <anschelsc@gmail.com>2010-08-06 16:39:18 -0700
commit6c8b96ca28939a92ac3460e5b304c850667679a5 (patch)
tree531f86c164911a9ae146f072fdd3f5e88a7dcc14
parentbf113dceb0936f42c2974944361453a82ac26c2d (diff)
downloadgo-6c8b96ca28939a92ac3460e5b304c850667679a5.tar.gz
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 <rsc@golang.org>
-rw-r--r--src/pkg/exp/iterable/array.go13
-rw-r--r--src/pkg/exp/iterable/iterable_test.go4
2 files changed, 17 insertions, 0 deletions
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)