github.com/ugorji/go/codec@v1.2.13-0.20240307214044-07c54c229a5a/goversion_maprange_gte_go112.go (about)

     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.12 && (safe || codec.safe || appengine)
     5  // +build go1.12
     6  // +build safe codec.safe appengine
     7  
     8  package codec
     9  
    10  import "reflect"
    11  
    12  type mapIter struct {
    13  	t      *reflect.MapIter
    14  	m      reflect.Value
    15  	values bool
    16  }
    17  
    18  func (t *mapIter) Next() (r bool) {
    19  	return t.t.Next()
    20  }
    21  
    22  func (t *mapIter) Key() reflect.Value {
    23  	return t.t.Key()
    24  }
    25  
    26  func (t *mapIter) Value() (r reflect.Value) {
    27  	if t.values {
    28  		return t.t.Value()
    29  	}
    30  	return
    31  }
    32  
    33  func (t *mapIter) Done() {}
    34  
    35  func mapRange(t *mapIter, m, k, v reflect.Value, values bool) {
    36  	*t = mapIter{
    37  		m:      m,
    38  		t:      m.MapRange(),
    39  		values: values,
    40  	}
    41  }