Files
consensus/utils/utils.go
T
zeekay af0bbdc3d6 feat: complete integration of all three consensus engines
- Implement chain, DAG, and post-quantum consensus engines with full test coverage
- Create IntegratedEngine in node package combining all three engines
- Add production-ready cmd tools (params, checker, sim, zmq-bench)
- Implement Acceptor interface for node consensus integration
- Add WithBlockTime method to config Parameters
- Ensure all tests pass across consensus and node packages
- Remove stub implementations and add proper production code
- Fix config validation with detailed error messages
- Clean up duplicate files and unused code
2025-08-21 19:25:56 -05:00

38 lines
792 B
Go

package utils
import (
"sort"
)
// Sort sorts a slice
func Sort[T any](slice []T, less func(i, j int) bool) {
sort.Slice(slice, less)
}
// SortByID sorts by ID
func SortByID[T interface{ ID() string }](slice []T) {
sort.Slice(slice, func(i, j int) bool {
return slice[i].ID() < slice[j].ID()
})
}
// Contains checks if slice contains element
func Contains[T comparable](slice []T, elem T) bool {
for _, v := range slice {
if v == elem {
return true
}
}
return false
}
// Filter filters a slice
func Filter[T any](slice []T, predicate func(T) bool) []T {
result := make([]T, 0, len(slice))
for _, v := range slice {
if predicate(v) {
result = append(result, v)
}
}
return result
}