From 94d9cc7741a13206e139efeab84fcc589dc390e5 Mon Sep 17 00:00:00 2001 From: Konstantin Shaposhnikov Date: Sat, 20 Aug 2016 19:29:01 +0800 Subject: [PATCH] index/suffixarray: add Lookup example Updates #16360 Change-Id: Idd8523b5a9a496ebd9c6e3b89c30df539842a139 Reviewed-on: https://go-review.googlesource.com/27433 Reviewed-by: C Cirello Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/index/suffixarray/example_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/index/suffixarray/example_test.go diff --git a/src/index/suffixarray/example_test.go b/src/index/suffixarray/example_test.go new file mode 100644 index 0000000000..ea10bfd06a --- /dev/null +++ b/src/index/suffixarray/example_test.go @@ -0,0 +1,22 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package suffixarray_test + +import ( + "fmt" + "index/suffixarray" +) + +func ExampleIndex_Lookup() { + index := suffixarray.New([]byte("banana")) + offsets := index.Lookup([]byte("ana"), -1) + for _, off := range offsets { + fmt.Println(off) + } + + // Unordered output: + // 1 + // 3 +}