]> Cypherpunks repositories - gostls13.git/commitdiff
exp/iterable: add UintArray
authorAnschel Schaffer-Cohen <anschelsc@gmail.com>
Fri, 6 Aug 2010 23:39:18 +0000 (16:39 -0700)
committerRuss Cox <rsc@golang.org>
Fri, 6 Aug 2010 23:39:18 +0000 (16:39 -0700)
all other basic types seem to be represented.

R=rsc
CC=golang-dev
https://golang.org/cl/1919042

src/pkg/exp/iterable/array.go
src/pkg/exp/iterable/iterable_test.go

index b5c7b5c6ead8c44f2c9b08bc2f6ebe1b9e8462d3..3ec79975128bc59b0bd919599d7d260c3a95f186 100644 (file)
@@ -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
+}
index 26a2eecc4554a33ead9ba8247140e4b619adb97b..23151578c1a96e722e79f4c50ec33b03b40a9632 100644 (file)
@@ -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)