Expected binaryheap to Pop int value when using NewWithIntComparator #177
Labels
No labels
bug
discussion
documentation
duplicate
ignore
new feature
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
golibs/gms-gods#177
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A heap created like
heap := binaryheap.NewWithIntComparator()is expected toPopint type element. Instead the method returns an interface that needs a type assertion. Is it possible to do this type assertion by the package itself as per the Comparator used.At the time of creating GoDS, there were no generics (as this is the case with golang 1.18). Hence, type assertions were mandatory everywhere and are take the biggest performance hit when it comes to GoDS. There is discussion and roadmap to take GoDS to generics which would avoid type assertions everywhere in GoDS v2.
As for now, GoDS v1, works everywhere with
interface{}types, hence the need to type assert. It's not the prettiest sight to see having to type assert everywhere, but it is not that bad either for now.At the time of creating GoDS, there were no generics (as this is the case with golang 1.18). Hence, type assertions were mandatory everywhere and are take the biggest performance hit when it comes to GoDS. There is discussion and roadmap to take GoDS to generics which would avoid type assertions everywhere in GoDS v2.
As for now, GoDS v1, works everywhere with
interface{}types, hence the need to type assert. It's not the prettiest sight to see having to type assert everywhere, but it is not that bad either for now.