Debian Codegraph @

codec/goversion_maprange_lt_go112.go

raw symbols SCIP
1 // Copyright (c) 2012-2020 Ugorji Nwoke. All rights reserved.
2 // Use of this source code is governed by a MIT license found in the LICENSE file.
3
4 //go:build go1.7 && !go1.12 && (safe || codec.safe || appengine)
5 // +build go1.7
6 // +build !go1.12
7 // +build safe codec.safe appengine
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 }