Files
utxo/secp256k1fx/sort_helpers.go
zeekay 8f7179ae0d refactor: move fx packages to root
Drop redundant fx/ directory since packages already have fx suffix:
- github.com/luxfi/utxo/fx/secp256k1fx → github.com/luxfi/utxo/secp256k1fx
- github.com/luxfi/utxo/fx/nftfx → github.com/luxfi/utxo/nftfx
- github.com/luxfi/utxo/fx/propertyfx → github.com/luxfi/utxo/propertyfx

BREAKING CHANGE: Import paths changed
2026-01-10 12:54:02 -08:00

34 lines
623 B
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package secp256k1fx
import (
"cmp"
"slices"
)
func sortByCompare[T interface{ Compare(T) int }](s []T) {
slices.SortFunc(s, func(a, b T) int {
return a.Compare(b)
})
}
func isSortedAndUniqueByCompare[T interface{ Compare(T) int }](s []T) bool {
for i := 1; i < len(s); i++ {
if s[i-1].Compare(s[i]) >= 0 {
return false
}
}
return true
}
func isSortedAndUniqueOrdered[T cmp.Ordered](s []T) bool {
for i := 1; i < len(s); i++ {
if s[i-1] >= s[i] {
return false
}
}
return true
}