suffixarray

package
v0.0.0-...-3805acb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package suffixarray implements substring search in logarithmic time using an in-memory suffix array.

It is derived from index/suffixarray in go std; the only difference is that it forces use of int32 for the index and exposes a single method LookupLongest that returns the longest match in a given range.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index struct {
	// contains filtered or unexported fields
}

Index implements a suffix array for fast substring search.

func New

func New(data []byte, sa []int32) *Index

New creates a new Index for data. Index creation time is O(N) for N = len(data).

func (*Index) Bytes

func (x *Index) Bytes() []byte

Bytes returns the data over which the index was created. It must not be modified.

func (*Index) LookupLongest

func (x *Index) LookupLongest(s []byte, minEnd, maxEnd, rangeStart, rangeEnd int) (index, length int)

LookupLongest returns an index and length of the longest substring of s[:minEnd] / s[:maxEnd] that occurs in the indexed data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL