type Length = Int
-func min(i Int, rest ...Int) Int {
- ret := i
- for _, i := range rest {
- if i < ret {
- ret = i
- }
- }
- return ret
-}
-
type Extent struct {
Start, Length Int
}
}
type (
- Callback = func(int, Extent) bool
+ Callback = func(segmentIndex int, segmentBounds Extent) bool
LengthIter = func() (Length, bool)
)
+// Returns true if callback returns false early, or all segments in the haystack for the needle are
+// found.
func Scan(haystack LengthIter, needle Extent, callback Callback) bool {
i := 0
for needle.Length != 0 {