github.com/haraldrudell/parl@v0.4.176/pmaps/pmaps2/key-ranger.go (about) 1 /* 2 © 2022–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/) 3 ISC License 4 */ 5 6 package pmaps2 7 8 // KeyRanger is a tuple value-type 9 // - used as local variable or function argument or return value causes 10 // no allocation 11 // - taking its address causes allocation 12 type KeyRanger[K comparable, V any] struct { 13 List []K 14 i int 15 } 16 17 // RangeFunc can be used with map Range methods 18 func (r KeyRanger[K, V]) RangeFunc(key K, value V) (keepGoing bool) { 19 r.List[r.i] = key 20 r.i++ 21 keepGoing = r.i < len(r.List) 22 return 23 }