github.com/jingcheng-WU/gonum@v0.9.1-0.20210323123734-f1a2a11a8f7b/graph/internal/set/same_appengine.go (about) 1 // Copyright ©2014 The Gonum Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build safe 6 7 package set 8 9 import "reflect" 10 11 // same determines whether two sets are backed by the same store. In the 12 // current implementation using hash maps it makes use of the fact that 13 // hash maps are passed as a pointer to a runtime Hmap struct. A map is 14 // not seen by the runtime as a pointer though, so we use reflect to get 15 // the maps' pointer values to compare. 16 func same(a, b Nodes) bool { 17 return reflect.ValueOf(a).Pointer() == reflect.ValueOf(b).Pointer() 18 } 19 20 // intsSame determines whether two sets are backed by the same store. In the 21 // current implementation using hash maps it makes use of the fact that 22 // hash maps are passed as a pointer to a runtime Hmap struct. A map is 23 // not seen by the runtime as a pointer though, so we use reflect to get 24 // the maps' pointer values to compare. 25 func intsSame(a, b Ints) bool { 26 return reflect.ValueOf(a).Pointer() == reflect.ValueOf(b).Pointer() 27 } 28 29 // int64sSame determines whether two sets are backed by the same store. In the 30 // current implementation using hash maps it makes use of the fact that 31 // hash maps are passed as a pointer to a runtime Hmap struct. A map is 32 // not seen by the runtime as a pointer though, so we use reflect to get 33 // the maps' pointer values to compare. 34 func int64sSame(a, b Int64s) bool { 35 return reflect.ValueOf(a).Pointer() == reflect.ValueOf(b).Pointer() 36 }