Skip to content

Commit 86f1f8e

Browse files
committed
rename package pq -> pqueue
1 parent 4b697de commit 86f1f8e

File tree

11 files changed

+26
-26
lines changed

11 files changed

+26
-26
lines changed

assets/examples/pq_binomial.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ package main
1717
import (
1818
"fmt"
1919

20-
"github.com/howz97/algorithm/pq"
20+
"github.com/howz97/algorithm/pqueue"
2121
)
2222

2323
func demo_binomial() {
24-
b := pq.NewBinomial[int]()
24+
b := pqueue.NewBinomial[int]()
2525
b.Push(1)
2626
b.Push(9)
2727
b.Push(9)
2828
b.Push(7)
29-
b2 := pq.NewBinomial[int]()
29+
b2 := pqueue.NewBinomial[int]()
3030
b2.Push(13)
3131
b2.Push(11)
3232
b.Merge(b2)

assets/examples/pq_leftist.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ package main
1717
import (
1818
"fmt"
1919

20-
"github.com/howz97/algorithm/pq"
20+
"github.com/howz97/algorithm/pqueue"
2121
)
2222

2323
func demo_leftist() {
24-
b := pq.NewLeftist[int]()
24+
b := pqueue.NewLeftist[int]()
2525
b.Push(1)
2626
b.Push(9)
2727
b.Push(9)
2828
b.Push(7)
29-
b2 := pq.NewLeftist[int]()
29+
b2 := pqueue.NewLeftist[int]()
3030
b2.Push(13)
3131
b2.Push(11)
3232
b.Merge(b2)

graphs/wdigraph.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"strconv"
2121

2222
"github.com/howz97/algorithm/basic"
23-
"github.com/howz97/algorithm/pq"
23+
"github.com/howz97/algorithm/pqueue"
2424
)
2525

2626
const (
@@ -133,15 +133,15 @@ func (spt *PathTree) PathTo(dst int) *Path {
133133
}
134134

135135
func (spt *PathTree) initDijkstra(g *WDigraph) {
136-
pq := pq.NewFixable[float64, int](g.NumVert())
136+
pq := pqueue.NewFixable[float64, int](g.NumVert())
137137
dijkstraRelax(g, spt.src, spt.edgeTo, spt.distTo, pq)
138138
for pq.Size() > 0 {
139139
m := pq.Pop()
140140
dijkstraRelax(g, m, spt.edgeTo, spt.distTo, pq)
141141
}
142142
}
143143

144-
func dijkstraRelax(g *WDigraph, v int, edgeTo []int, distTo []float64, pq *pq.Fixable[float64, int]) {
144+
func dijkstraRelax(g *WDigraph, v int, edgeTo []int, distTo []float64, pq *pqueue.Fixable[float64, int]) {
145145
g.IterWAdjacent(v, func(adj int, w float64) bool {
146146
if distTo[v]+w < distTo[adj] {
147147
inPQ := distTo[adj] != math.Inf(1)

graphs/wgraph.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package graphs
1616

1717
import (
1818
"github.com/howz97/algorithm/basic"
19-
"github.com/howz97/algorithm/pq"
19+
"github.com/howz97/algorithm/pqueue"
2020
)
2121

2222
func NewWGraph(size uint) *WGraph {
@@ -35,7 +35,7 @@ func (g *WGraph) AddEdge(src, dst int, w float64) error {
3535

3636
// LazyPrim gets the minimum spanning tree by Lazy-Prim algorithm. g MUST be a connected graph
3737
func (g *WGraph) LazyPrim() (mst *WGraph) {
38-
pq := pq.NewPaired[float64, *edge](g.NumVert())
38+
pq := pqueue.NewPaired[float64, *edge](g.NumVert())
3939
mst = NewWGraph(g.NumVert())
4040
marked := make([]bool, g.NumVert())
4141
marked[0] = true
@@ -58,7 +58,7 @@ func (g *WGraph) LazyPrim() (mst *WGraph) {
5858
return
5959
}
6060

61-
func lazyPrimVisit(g *WGraph, v int, marked []bool, pq *pq.Paired[float64, *edge]) {
61+
func lazyPrimVisit(g *WGraph, v int, marked []bool, pq *pqueue.Paired[float64, *edge]) {
6262
marked[v] = true
6363
g.IterWAdjacent(v, func(a int, w float64) bool {
6464
if !marked[a] {
@@ -75,7 +75,7 @@ func lazyPrimVisit(g *WGraph, v int, marked []bool, pq *pq.Paired[float64, *edge
7575
// Prim gets the minimum spanning tree by Prim algorithm. g MUST be a connected graph
7676
func (g *WGraph) Prim() (mst *WGraph) {
7777
marked := make([]bool, g.NumVert())
78-
pq := pq.NewFixable[float64, int](g.NumVert())
78+
pq := pqueue.NewFixable[float64, int](g.NumVert())
7979
mst = NewWGraph(g.NumVert())
8080
marked[0] = true
8181
g.IterWAdjacent(0, func(a int, w float64) bool {
@@ -92,7 +92,7 @@ func (g *WGraph) Prim() (mst *WGraph) {
9292
return
9393
}
9494

95-
func primVisit(g, mst *WGraph, v int, marked []bool, pq *pq.Fixable[float64, int]) {
95+
func primVisit(g, mst *WGraph, v int, marked []bool, pq *pqueue.Fixable[float64, int]) {
9696
marked[v] = true
9797
g.IterWAdjacent(v, func(a int, w float64) bool {
9898
if marked[a] {
@@ -115,7 +115,7 @@ func primVisit(g, mst *WGraph, v int, marked []bool, pq *pq.Fixable[float64, int
115115
func (g *WGraph) Kruskal() (mst *WGraph) {
116116
mst = NewWGraph(g.NumVert())
117117
uf := basic.NewUnionFind(int(g.NumVert()))
118-
pq := pq.NewPaired[float64, *edge](g.NumVert())
118+
pq := pqueue.NewPaired[float64, *edge](g.NumVert())
119119
g.IterWEdge(func(src int, dst int, w float64) bool {
120120
pq.PushPair(w, &edge{
121121
from: src,

pq/binomial.go pqueue/binomial.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package pq
15+
package pqueue
1616

1717
import "cmp"
1818

pq/binomial_test.go pqueue/binomial_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package pq
15+
package pqueue
1616

1717
import (
1818
"fmt"

pq/heap.go pqueue/heap.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package pq
15+
package pqueue
1616

1717
import (
1818
"cmp"

pq/interface.go pqueue/interface.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package pq
15+
package pqueue
1616

1717
import "cmp"
1818

pq/leftist.go pqueue/leftist.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package pq
15+
package pqueue
1616

1717
import "cmp"
1818

pq/pq_test.go pqueue/pqueue_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
// limitations under the License.
1414

1515
/*
16-
go test -bench="^Benchmark.*_Push" -cpu=1 -benchtime=10000000x github.com/howz97/algorithm/pq
17-
go test -bench="^Benchmark.*_Pop" -cpu=1 -benchtime=1000000x github.com/howz97/algorithm/pq
18-
go test -bench="^Benchmark.*_Merge" -cpu=1 -benchtime=10000x github.com/howz97/algorithm/pq
16+
go test -bench="^Benchmark.*_Push" -cpu=1 -benchtime=10000000x github.com/howz97/algorithm/pqueue
17+
go test -bench="^Benchmark.*_Pop" -cpu=1 -benchtime=1000000x github.com/howz97/algorithm/pqueue
18+
go test -bench="^Benchmark.*_Merge" -cpu=1 -benchtime=10000x github.com/howz97/algorithm/pqueue
1919
*/
20-
package pq
20+
package pqueue
2121

2222
import (
2323
"fmt"

strings/compress/huffman.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package compress
1717
import (
1818
"strconv"
1919

20-
"github.com/howz97/algorithm/pq"
20+
"github.com/howz97/algorithm/pqueue"
2121
"github.com/howz97/algorithm/search"
2222
)
2323

@@ -105,7 +105,7 @@ func genHuffmanTree(data []byte) (huffmanTree *node) {
105105
for _, b := range data {
106106
stat[b]++
107107
}
108-
pq := pq.NewPaired[int, *node](256)
108+
pq := pqueue.NewPaired[int, *node](256)
109109
for b, cnt := range stat {
110110
if cnt > 0 {
111111
pq.PushPair(cnt, &node{

0 commit comments

Comments
 (0)