Documentation
¶
Overview ¶
Copyright (c) 2025 Nikita Kamenev Licensed under the MIT License. See LICENSE file in the project root for details.
Copyright (c) 2025 Nikita Kamenev Licensed under the MIT License. See LICENSE file in the project root for details.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SuffixArray ¶
type SuffixArray struct {
// contains filtered or unexported fields
}
SuffixArray represents a suffix array for a given text. It stores the original text and the suffix array (indices of suffixes in lexicographical order).
func New ¶
func New(text []int32) *SuffixArray
New creates a new SuffixArray for the given text. Parameters: - text: input text as a slice of int32. Returns a pointer to the constructed SuffixArray.
func (*SuffixArray) Lookup ¶
func (sa *SuffixArray) Lookup(prefix []int32) []int32
Lookup finds all suffixes that start with the given prefix. Parameters: - prefix: prefix to search for (slice of int32). Returns a slice of indices from the suffix array where suffixes start with the prefix, in lexicographical order of the suffixes.
func (*SuffixArray) LookupSuffix ¶
func (sa *SuffixArray) LookupSuffix(suffix []int32) int
LookupSuffix finds the exact suffix in the text. Parameters: - suffix: suffix to search for (slice of int32). Returns: - -1 if the suffix is not found or invalid input is provided. - The index in the text where the suffix starts if found.
func (*SuffixArray) LookupTextOrder ¶
func (sa *SuffixArray) LookupTextOrder(prefix []int32) []int32
LookupTextOrd finds all suffixes that start with the given prefix and returns their indices in the order they appear in the original text. Parameters: - prefix: prefix to search for (slice of int32). Returns a slice of indices sorted by their position in the text.