mirror of
https://github.com/gonum/gonum.git
synced 2025-10-08 08:30:14 +08:00
graph/internal/...: update for int64 IDs
This commit is contained in:
@@ -7,7 +7,7 @@ package set // import "gonum.org/v1/gonum/graph/internal/set"
|
||||
|
||||
import "gonum.org/v1/gonum/graph"
|
||||
|
||||
// Ints is a set of integer identifiers.
|
||||
// Ints is a set of int identifiers.
|
||||
type Ints map[int]struct{}
|
||||
|
||||
// The simple accessor methods for Ints are provided to allow ease of
|
||||
@@ -54,8 +54,55 @@ func IntsEqual(a, b Ints) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Int64s is a set of int64 identifiers.
|
||||
type Int64s map[int64]struct{}
|
||||
|
||||
// The simple accessor methods for Ints are provided to allow ease of
|
||||
// implementation change should the need arise.
|
||||
|
||||
// Add inserts an element into the set.
|
||||
func (s Int64s) Add(e int64) {
|
||||
s[e] = struct{}{}
|
||||
}
|
||||
|
||||
// Has reports the existence of the element in the set.
|
||||
func (s Int64s) Has(e int64) bool {
|
||||
_, ok := s[e]
|
||||
return ok
|
||||
}
|
||||
|
||||
// Remove deletes the specified element from the set.
|
||||
func (s Int64s) Remove(e int64) {
|
||||
delete(s, e)
|
||||
}
|
||||
|
||||
// Count reports the number of elements stored in the set.
|
||||
func (s Int64s) Count() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
// Int64sEqual reports set equality between the parameters. Sets are equal if
|
||||
// and only if they have the same elements.
|
||||
func Int64sEqual(a, b Int64s) bool {
|
||||
if int64sSame(a, b) {
|
||||
return true
|
||||
}
|
||||
|
||||
if len(a) != len(b) {
|
||||
return false
|
||||
}
|
||||
|
||||
for e := range a {
|
||||
if _, ok := b[e]; !ok {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Nodes is a set of nodes keyed in their integer identifiers.
|
||||
type Nodes map[int]graph.Node
|
||||
type Nodes map[int64]graph.Node
|
||||
|
||||
// The simple accessor methods for Nodes are provided to allow ease of
|
||||
// implementation change should the need arise.
|
||||
|
Reference in New Issue
Block a user