Generics migration (#237)

* Generics migration

This attempts to migrate this library in the least invasive way by preserving as
much of the original API as possible. It does not change the tests in a
meaningful way nor does it attempt to upgrade any logic that can be simplified
or improved with generics. This is purely an API migration, and still requires a
lot of additional work to be fully ready.

* Fix a few broken tests around serialization

* Add v2 suffix

* Temporarily change mod name for testing

* Rename module to /v2
This commit is contained in:
Paul Chesnais
2024-01-06 19:06:17 -05:00
committed by GitHub
parent 10d6c5b4f2
commit 14f714261f
135 changed files with 3254 additions and 4083 deletions
+5 -6
View File
@@ -5,8 +5,9 @@
package main
import (
pq "github.com/emirpasic/gods/queues/priorityqueue"
"github.com/emirpasic/gods/utils"
"cmp"
pq "github.com/emirpasic/gods/v2/queues/priorityqueue"
)
// Element is an entry in the priority queue
@@ -16,10 +17,8 @@ type Element struct {
}
// Comparator function (sort by element's priority value in descending order)
func byPriority(a, b interface{}) int {
priorityA := a.(Element).priority
priorityB := b.(Element).priority
return -utils.IntComparator(priorityA, priorityB) // "-" descending order
func byPriority(a, b Element) int {
return -cmp.Compare(a.priority, b.priority) // "-" descending order
}
// PriorityQueueExample to demonstrate basic usage of BinaryHeap