1
0
mirror of https://github.com/golang/go synced 2024-11-25 02:27:56 -07:00

exp/iterable: add UintArray

all other basic types seem to be represented.

R=rsc
CC=golang-dev
https://golang.org/cl/1919042
This commit is contained in:
Anschel Schaffer-Cohen 2010-08-06 16:39:18 -07:00 committed by Russ Cox
parent 8c5f30c0d9
commit 8055f47029
2 changed files with 17 additions and 0 deletions

View File

@ -57,3 +57,16 @@ func (a StringArray) Iter() <-chan interface{} {
}() }()
return ch 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
}

View File

@ -15,6 +15,10 @@ func TestArrayTypes(t *testing.T) {
if x := Data(bytes)[1].(byte); x != 2 { if x := Data(bytes)[1].(byte); x != 2 {
t.Error("Data(bytes)[1].(byte) = %v, want 2", x) 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}) ints := IntArray([]int{1, 2, 3})
if x := Data(ints)[2].(int); x != 3 { if x := Data(ints)[2].(int); x != 3 {
t.Error("Data(ints)[2].(int) = %v, want 3", x) t.Error("Data(ints)[2].(int) = %v, want 3", x)