func ExampleStringFinder() {
	p := []byte("foo")
	t1 := []byte("bar foo wing ding foo monkey")
	t2 := []byte("monkey foo ding wing foo bar")

	// If we want to find all occurences of p in t1 it is as simple as this:
	stringz.Find(p).In(t1)

	// We can also store the StringFinder for use later so we don't incur the
	// overhead of preprocessing p multiple times.
	find_foo := stringz.Find(p)
	hits1 := find_foo.In(t1)
	hits2 := find_foo.In(t2)
	fmt.Printf("%v %v\n", hits1, hits2)
	// Output:
	// [4 18] [7 21]
}
示例#2
0
func Check(c *SlowCMWC, max int) int {
	for i := range c.Q {
		c.Q[i] = uint64(uint64(source.Uint32()) % c.B)
	}
	seq := make([]byte, max*3)
	for i := range seq {
		seq[i] = byte(c.Next())
	}
	res := stringz.Find(seq[0:10]).In(seq)
	if len(res) <= 1 {
		return 0
	}
	return res[1]
}