summaryrefslogtreecommitdiff
path: root/lib/slices
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-03-17 18:38:14 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2023-03-17 18:38:14 -0400
commit0f85e72d1331b49b52925d6cc5ad083a0376104c (patch)
tree9ba66e893d6f66096f6b06284d09c8eb3e50facc /lib/slices
parentc0f33186aa7a8903c5e7406024f13fad48cd14e3 (diff)
parent1ea26f04701fa66e36b058f3efb3a6c7059cdc5c (diff)
Merge branch 'lukeshu/lint'
Diffstat (limited to 'lib/slices')
-rw-r--r--lib/slices/sliceutil.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/slices/sliceutil.go b/lib/slices/sliceutil.go
index 567f9ec..b8823d3 100644
--- a/lib/slices/sliceutil.go
+++ b/lib/slices/sliceutil.go
@@ -1,7 +1,9 @@
-// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com>
+// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later
+// Package slices implements generic (type-parameterized) utilities
+// for working with simple Go slices.
package slices
import (
@@ -93,7 +95,7 @@ func max(a, b int) int {
return b
}
-// Search the slice for a value for which `fn(slice[i]) = 0`.
+// Search searches the slice for a value for which `fn(slice[i]) = 0`.
//
// : + + + 0 0 0 - - -
// : ^ ^ ^
@@ -121,7 +123,8 @@ func Search[T any](slice []T, fn func(T) int) (int, bool) {
return 0, false
}
-// Search the slice for the left-most value for which `fn(slice[i]) = 0`.
+// SearchLowest searches the slice for the left-most value for which
+// `fn(slice[i]) = 0`.
//
// : + + + 0 0 0 - - -
// : ^
@@ -151,7 +154,8 @@ func SearchLowest[T any](slice []T, fn func(T) int) (int, bool) {
return firstGood, true
}
-// Search the slice for the right-most value for which `fn(slice[i]) = 0`.
+// SearchHighest searches the slice for the right-most value for which
+// `fn(slice[i]) = 0`.
//
// : + + + 0 0 0 - - -
// : ^