mirror of
https://github.com/luxfi/math.git
synced 2026-07-27 01:24:06 +00:00
- Add Zero[T any]() generic function for zero values - Add IsSortedBytes for byte slice sorting checks - Add heap/queue.go with priority Queue[T] implementation - Add heap/map.go with indexed Map[K,V] for heap operations - Add linked/list.go with doubly-linked List[T] - Add linked/hashmap.go with ordered HashMap[K,V] - Update sampleable_set.go to use local luxmath.Zero[T]() - Update averager_heap.go to use github.com/luxfi/math/heap - Update safe_math.go to use luxmath.Zero[T]() - Remove github.com/luxfi/utils dependency entirely
17 lines
366 B
Go
17 lines
366 B
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package math
|
|
|
|
import "bytes"
|
|
|
|
// IsSortedBytes returns true if s is sorted in ascending order.
|
|
func IsSortedBytes[T ~[]byte](s []T) bool {
|
|
for i := 0; i < len(s)-1; i++ {
|
|
if bytes.Compare(s[i], s[i+1]) == 1 {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|