fix(package): [algorithm] handle empty iterative searches (#399)

This commit is contained in:
Yusuf Efe authored and GitHub committed 2026-10-22 10:28:04 +08:00
1 parent 13b7b1c61e
commit e49a01e725
2 files changed
+14

No files matched your search

+3
View File
@@ -45,6 +45,9 @@ func BinarySearch[T any](sortedSlice []T, target T, lowIndex, highIndex int, com
// If not found return -1.
// Play: https://go.dev/play/p/Anozfr8ZLH3
func BinaryIterativeSearch[T any](sortedSlice []T, target T, lowIndex, highIndex int, comparator constraints.Comparator) int {
if len(sortedSlice) == 0 {
return -1
}
startIndex := lowIndex
endIndex := highIndex