gonum.org/v1/gonum@v0.14.0/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  //go:build safe
     6  // +build safe
     7  
     8  package set
     9  
    10  import "reflect"
    11  
    12  // same determines whether two sets are backed by the same store. In the
    13  // current implementation using hash maps it makes use of the fact that
    14  // hash maps are passed as a pointer to a runtime Hmap struct. A map is
    15  // not seen by the runtime as a pointer though, so we use reflect to get
    16  // the maps' pointer values to compare.
    17  func same(a, b Nodes) bool {
    18  	return reflect.ValueOf(a).Pointer() == reflect.ValueOf(b).Pointer()
    19  }
    20  
    21  // intsSame determines whether two sets are backed by the same store. In the
    22  // current implementation using hash maps it makes use of the fact that
    23  // hash maps are passed as a pointer to a runtime Hmap struct. A map is
    24  // not seen by the runtime as a pointer though, so we use reflect to get
    25  // the maps' pointer values to compare.
    26  func intsSame(a, b Ints) bool {
    27  	return reflect.ValueOf(a).Pointer() == reflect.ValueOf(b).Pointer()
    28  }
    29  
    30  // int64sSame determines whether two sets are backed by the same store. In the
    31  // current implementation using hash maps it makes use of the fact that
    32  // hash maps are passed as a pointer to a runtime Hmap struct. A map is
    33  // not seen by the runtime as a pointer though, so we use reflect to get
    34  // the maps' pointer values to compare.
    35  func int64sSame(a, b Int64s) bool {
    36  	return reflect.ValueOf(a).Pointer() == reflect.ValueOf(b).Pointer()
    37  }