match294%python.module
fault.context

Naive prefix searching implementations.

collections
import

typing0
import

SubsequenceScan0
class

Subsequence search implementation based on scanning the possible sizes and checking the candidate subsequence's presence in a set.

This naive implementation is O(N) (hash checks and subsequence) worst case for first match, so it is inappropriate for large sets.

However, when used as part of a tree where the sequence is kept small, it may be a reasonable implmentation selection.

SubsequenceScanProperties

sequences

The set of sequences that will be scanned by matches.

sizes

The ordered sequence of slice sizes that sources the match search.

offset

The starting point of the subsequence's slice; usually zero.

SubsequenceScan__init__0
method

__init__(self, sequences, offset, order)

Create a SubsequenceScan from the given set of sequences.

SubsequenceScan__init__Parameters

self

Undocumented.

sequences
  • typing.Sequence[typing.Hashable]

A sequence of sequences to scan. Usually, a list of str instances. This is transformed into a set of sequences.

offset

The start of the subsequence to check; usually 0.

order

True means to match the longest subsequence first, and False means to match the shortest first. When False, the longest match will never be the first occurrence.

SubsequenceScanadd0
method

add(self, *values)

Add new values to the set of sequences.

WARNING

Implementation reconstructs the sizes sequence every call.

SubsequenceScandiscard0
method

discard(self, *values)

Remove values from the set of sequences.

WARNING

Implementation reconstructs the sizes sequence every call.

SubsequenceScanmatches0
method

matches(self, key)

Identify all strings in the set that match the given key based on the configured offset.

SubsequenceScanget166%
method

get(self, key)

SubsequenceScan__contains__0
method

__contains__(self, key)

SubsequenceScan__getitem__0
method

__getitem__(self, key)

Get the first match in the set of strings.

SubsequenceScanvalues0
method

values(self)

SubsequenceScankeys10%
method

keys(self)