...
1
2
3
4
5
6
7
8
9 package codec
10
11 import "reflect"
12
13 type mapIter struct {
14 m reflect.Value
15 keys []reflect.Value
16 j int
17 values bool
18 }
19
20 func (t *mapIter) Next() (r bool) {
21 t.j++
22 return t.j < len(t.keys)
23 }
24
25 func (t *mapIter) Key() reflect.Value {
26 return t.keys[t.j]
27 }
28
29 func (t *mapIter) Value() (r reflect.Value) {
30 if t.values {
31 return t.m.MapIndex(t.keys[t.j])
32 }
33 return
34 }
35
36 func (t *mapIter) Done() {}
37
38 func mapRange(t *mapIter, m, k, v reflect.Value, values bool) {
39 *t = mapIter{
40 m: m,
41 keys: m.MapKeys(),
42 values: values,
43 j: -1,
44 }
45 }
46
View as plain text