Skip to content

Commit

Permalink
index/suffixarray: add Lookup example
Browse files Browse the repository at this point in the history
Updates golang#16360

Change-Id: Idd8523b5a9a496ebd9c6e3b89c30df539842a139
Reviewed-on: https://go-review.googlesource.com/27433
Reviewed-by: C Cirello <uldericofilho@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
  • Loading branch information
kostya-sh authored and bradfitz committed Aug 21, 2016
1 parent 7995cb8 commit 94d9cc7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/index/suffixarray/example_test.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 94d9cc7

Please sign in to comment.