Skip to content

GeneralizedSuffixArray

Defined in: packages/data/src/substring/generalized-suffix-array.ts:30

A substring index over many strings at once.

The documents are concatenated with a separator and indexed as one SuffixArray, so “which documents contain this substring” costs one search rather than one per document — the difference between O(m log N) and O(d · m log n).

Static, like SuffixArray: the whole corpus is given at construction.

If any document contains U+0000, which is reserved as the internal separator.

new GeneralizedSuffixArray(documents): GeneralizedSuffixArray

Defined in: packages/data/src/substring/generalized-suffix-array.ts:36

readonly string[]

GeneralizedSuffixArray

readonly documents: readonly string[]

Defined in: packages/data/src/substring/generalized-suffix-array.ts:36

count(): number

Defined in: packages/data/src/substring/generalized-suffix-array.ts:57

The number of documents indexed.

number


has(needle): boolean

Defined in: packages/data/src/substring/generalized-suffix-array.ts:89

O(m log N).

string

boolean

ISubstringIndex.has


matches(needle): IterableIterator<DocumentMatch>

Defined in: packages/data/src/substring/generalized-suffix-array.ts:98

Every occurrence, as a document index and an offset within it.

string

IterableIterator<DocumentMatch>


search(needle): IterableIterator<number>

Defined in: packages/data/src/substring/generalized-suffix-array.ts:67

The indices of every document containing needle, ascending and deduplicated.

Use matches for the offsets within each document.

string

IterableIterator<number>

ISubstringIndex.search