graph/set/uid: make uid package publicly available
MODIFY
graph/multi/directed.go
graph/multi/directed.go
@@ -8,8 +8,8 @@ import (
"fmt"
"gonum.org/v1/gonum/graph"
- "gonum.org/v1/gonum/graph/internal/uid"
"gonum.org/v1/gonum/graph/iterator"
+ "gonum.org/v1/gonum/graph/set/uid"
)
var (
@@ -31,7 +31,7 @@ type DirectedGraph struct {
from map[int64]map[int64]map[int64]graph.Line
to map[int64]map[int64]map[int64]graph.Line
- nodeIDs uid.Set
+ nodeIDs *uid.Set
lineIDs map[int64]map[int64]*uid.Set
}
@@ -147,11 +147,11 @@ func (g *DirectedGraph) NewLine(from, to graph.Node) graph.Line {
case g.lineIDs[fid] == nil:
uids := uid.NewSet()
lineID = uids.NewID()
- g.lineIDs[fid] = map[int64]*uid.Set{tid: &uids}
+ g.lineIDs[fid] = map[int64]*uid.Set{tid: uids}
case g.lineIDs[fid][tid] == nil:
uids := uid.NewSet()
lineID = uids.NewID()
- g.lineIDs[fid][tid] = &uids
+ g.lineIDs[fid][tid] = uids
default:
lineID = g.lineIDs[fid][tid].NewID()
}
@@ -272,10 +272,10 @@ func (g *DirectedGraph) SetLine(l graph.Line) {
switch {
case g.lineIDs[fid] == nil:
uids := uid.NewSet()
- g.lineIDs[fid] = map[int64]*uid.Set{tid: &uids}
+ g.lineIDs[fid] = map[int64]*uid.Set{tid: uids}
case g.lineIDs[fid][tid] == nil:
uids := uid.NewSet()
- g.lineIDs[fid][tid] = &uids
+ g.lineIDs[fid][tid] = uids
}
g.lineIDs[fid][tid].Use(lid)
}

MODIFY
graph/multi/undirected.go
graph/multi/undirected.go
@@ -8,8 +8,8 @@ import (
"fmt"
"gonum.org/v1/gonum/graph"
- "gonum.org/v1/gonum/graph/internal/uid"
"gonum.org/v1/gonum/graph/iterator"
+ "gonum.org/v1/gonum/graph/set/uid"
)
var (
@@ -30,7 +30,7 @@ type UndirectedGraph struct {
nodes map[int64]graph.Node
lines map[int64]map[int64]map[int64]graph.Line
- nodeIDs uid.Set
+ nodeIDs *uid.Set
lineIDs map[int64]map[int64]*uid.Set
}
@@ -156,11 +156,11 @@ func (g *UndirectedGraph) NewLine(from, to graph.Node) graph.Line {
case g.lineIDs[xid] == nil:
uids := uid.NewSet()
lineID = uids.NewID()
- g.lineIDs[xid] = map[int64]*uid.Set{yid: &uids}
+ g.lineIDs[xid] = map[int64]*uid.Set{yid: uids}
case g.lineIDs[xid][yid] == nil:
uids := uid.NewSet()
lineID = uids.NewID()
- g.lineIDs[xid][yid] = &uids
+ g.lineIDs[xid][yid] = uids
default:
lineID = g.lineIDs[xid][yid].NewID()
}
@@ -286,10 +286,10 @@ func (g *UndirectedGraph) SetLine(l graph.Line) {
switch {
case g.lineIDs[xid] == nil:
uids := uid.NewSet()
- g.lineIDs[xid] = map[int64]*uid.Set{yid: &uids}
+ g.lineIDs[xid] = map[int64]*uid.Set{yid: uids}
case g.lineIDs[xid][yid] == nil:
uids := uid.NewSet()
- g.lineIDs[xid][yid] = &uids
+ g.lineIDs[xid][yid] = uids
}
g.lineIDs[xid][yid].Use(lid)
}

MODIFY
graph/multi/weighted_directed.go
graph/multi/weighted_directed.go
@@ -8,8 +8,8 @@ import (
"fmt"
"gonum.org/v1/gonum/graph"
- "gonum.org/v1/gonum/graph/internal/uid"
"gonum.org/v1/gonum/graph/iterator"
+ "gonum.org/v1/gonum/graph/set/uid"
)
var (
@@ -40,7 +40,7 @@ type WeightedDirectedGraph struct {
from map[int64]map[int64]map[int64]graph.WeightedLine
to map[int64]map[int64]map[int64]graph.WeightedLine
- nodeIDs uid.Set
+ nodeIDs *uid.Set
lineIDs map[int64]map[int64]*uid.Set
}
@@ -167,11 +167,11 @@ func (g *WeightedDirectedGraph) NewWeightedLine(from, to graph.Node, weight floa
case g.lineIDs[fid] == nil:
uids := uid.NewSet()
lineID = uids.NewID()
- g.lineIDs[fid] = map[int64]*uid.Set{tid: &uids}
+ g.lineIDs[fid] = map[int64]*uid.Set{tid: uids}
case g.lineIDs[fid][tid] == nil:
uids := uid.NewSet()
lineID = uids.NewID()
- g.lineIDs[fid][tid] = &uids
+ g.lineIDs[fid][tid] = uids
default:
lineID = g.lineIDs[fid][tid].NewID()
}
@@ -280,10 +280,10 @@ func (g *WeightedDirectedGraph) SetWeightedLine(l graph.WeightedLine) {
switch {
case g.lineIDs[fid] == nil:
uids := uid.NewSet()
- g.lineIDs[fid] = map[int64]*uid.Set{tid: &uids}
+ g.lineIDs[fid] = map[int64]*uid.Set{tid: uids}
case g.lineIDs[fid][tid] == nil:
uids := uid.NewSet()
- g.lineIDs[fid][tid] = &uids
+ g.lineIDs[fid][tid] = uids
}
g.lineIDs[fid][tid].Use(lid)
}

MODIFY
graph/multi/weighted_undirected.go
graph/multi/weighted_undirected.go
@@ -8,8 +8,8 @@ import (
"fmt"
"gonum.org/v1/gonum/graph"
- "gonum.org/v1/gonum/graph/internal/uid"
"gonum.org/v1/gonum/graph/iterator"
+ "gonum.org/v1/gonum/graph/set/uid"
)
var (
@@ -39,7 +39,7 @@ type WeightedUndirectedGraph struct {
nodes map[int64]graph.Node
lines map[int64]map[int64]map[int64]graph.WeightedLine
- nodeIDs uid.Set
+ nodeIDs *uid.Set
lineIDs map[int64]map[int64]*uid.Set
}
@@ -174,11 +174,11 @@ func (g *WeightedUndirectedGraph) NewWeightedLine(from, to graph.Node, weight fl
case g.lineIDs[xid] == nil:
uids := uid.NewSet()
lineID = uids.NewID()
- g.lineIDs[xid] = map[int64]*uid.Set{yid: &uids}
+ g.lineIDs[xid] = map[int64]*uid.Set{yid: uids}
case g.lineIDs[xid][yid] == nil:
uids := uid.NewSet()
lineID = uids.NewID()
- g.lineIDs[xid][yid] = &uids
+ g.lineIDs[xid][yid] = uids
default:
lineID = g.lineIDs[xid][yid].NewID()
}
@@ -292,10 +292,10 @@ func (g *WeightedUndirectedGraph) SetWeightedLine(l graph.WeightedLine) {
switch {
case g.lineIDs[xid] == nil:
uids := uid.NewSet()
- g.lineIDs[xid] = map[int64]*uid.Set{yid: &uids}
+ g.lineIDs[xid] = map[int64]*uid.Set{yid: uids}
case g.lineIDs[xid][yid] == nil:
uids := uid.NewSet()
- g.lineIDs[xid][yid] = &uids
+ g.lineIDs[xid][yid] = uids
}
g.lineIDs[xid][yid].Use(lid)
}

RENAME
graph/internal/uid/uid.go
graph/set/uid/uid.go
@@ -20,10 +20,9 @@ type Set struct {
used, free set.Int64s
}
-// NewSet returns a new Set. The returned value should not be passed
-// except by pointer.
-func NewSet() Set {
- return Set{maxID: -1, used: make(set.Int64s), free: make(set.Int64s)}
+// NewSet returns a new Set.
+func NewSet() *Set {
+ return &Set{maxID: -1, used: make(set.Int64s), free: make(set.Int64s)}
}
// NewID returns a new unique ID. The ID returned is not considered used

RENAME
graph/internal/uid/uid_test.go
graph/set/uid/uid_test.go
MODIFY
graph/simple/directed.go
graph/simple/directed.go
@@ -8,8 +8,8 @@ import (
"fmt"
"gonum.org/v1/gonum/graph"
- "gonum.org/v1/gonum/graph/internal/uid"
"gonum.org/v1/gonum/graph/iterator"
+ "gonum.org/v1/gonum/graph/set/uid"
)
var (
@@ -29,7 +29,7 @@ type DirectedGraph struct {
from map[int64]map[int64]graph.Edge
to map[int64]map[int64]graph.Edge
- nodeIDs uid.Set
+ nodeIDs *uid.Set
}
// NewDirectedGraph returns a DirectedGraph.

MODIFY
graph/simple/undirected.go
graph/simple/undirected.go
@@ -8,8 +8,8 @@ import (
"fmt"
"gonum.org/v1/gonum/graph"
- "gonum.org/v1/gonum/graph/internal/uid"
"gonum.org/v1/gonum/graph/iterator"
+ "gonum.org/v1/gonum/graph/set/uid"
)
var (
@@ -28,7 +28,7 @@ type UndirectedGraph struct {
nodes map[int64]graph.Node
edges map[int64]map[int64]graph.Edge
- nodeIDs uid.Set
+ nodeIDs *uid.Set
}
// NewUndirectedGraph returns an UndirectedGraph.

MODIFY
graph/simple/weighted_directed.go
graph/simple/weighted_directed.go
@@ -8,8 +8,8 @@ import (
"fmt"
"gonum.org/v1/gonum/graph"
- "gonum.org/v1/gonum/graph/internal/uid"
"gonum.org/v1/gonum/graph/iterator"
+ "gonum.org/v1/gonum/graph/set/uid"
)
var (
@@ -33,7 +33,7 @@ type WeightedDirectedGraph struct {
self, absent float64
- nodeIDs uid.Set
+ nodeIDs *uid.Set
}
// NewWeightedDirectedGraph returns a WeightedDirectedGraph with the specified self and absent

MODIFY
graph/simple/weighted_undirected.go
graph/simple/weighted_undirected.go
@@ -8,8 +8,8 @@ import (
"fmt"
"gonum.org/v1/gonum/graph"
- "gonum.org/v1/gonum/graph/internal/uid"
"gonum.org/v1/gonum/graph/iterator"
+ "gonum.org/v1/gonum/graph/set/uid"
)
var (
@@ -32,7 +32,7 @@ type WeightedUndirectedGraph struct {
self, absent float64
- nodeIDs uid.Set
+ nodeIDs *uid.Set
}
// NewWeightedUndirectedGraph returns an WeightedUndirectedGraph with the specified self and absent

graph/set/uid: make uid package publicly available