Class FindFirst

Summary

Finds substrings in the order in which they appear in the subject string. If the substrings are submitted as a list, then the substrings are matched in order (i.e. given two potential matches [because one is a prefix of the other] FindFirst matches the first one found in the list). To find the shortest substring first, sort the list. To find the longest substring first, sort the list in reverse order.

This is a class to avoid the overhead of creating the internal structures on each invocation (while allowing different instances of FirstFirst to be used concurrently).

Superclasses:
Object

Package:
util
File:
scan_util.icn
Methods:
clearMatch, getMatch, locate, moveMatch, setKeys

Methods inherited from Object:
Type, className, clone, equals, fieldNames, genMethods, getField, get_class, get_class_name, get_id, hasField, hasMethod, hash_code, instanceOf, invoke, is_instance, setField, to_string

Fields:
cMaps, fchars, lastMatch, subs

Source code.

Details
Constructor

FindFirst(a)

 a collection of substrings

Methods:

clearMatch()

Forget the last matched substring.


getMatch()

Returns:
last matched substring from call to locate()

Produce the last matched substring. (Only valid if locate() succeeded!)


locate(s, i, j)

Parameters:
s
subject, defaults to &subject
i
start position, defaults to &pos
j
final position, defaults to 0
Generates:
positions (left-to-right) of matched substrings

Like find, but locates substrings in the order of their appearance in the subject string. This is a matching procedure.


moveMatch()

Returns:
matched substring

Move past the match, returning it. Fails if no match yet or if the scan position has been moved since the last call to locate(). This is a matching procedure.


setKeys(a)

Change the set of substrings to look for. Not normally used externally.

a set of substrings


Fields:
cMaps

fchars

lastMatch

subs


This page produced by UniDoc on 2021/04/15 @ 23:59:53.