public abstract class StringSearch extends Object implements Lang.Func3<char[],char[],Integer,Integer>
Modifier and Type | Class and Description |
---|---|
static class |
StringSearch.SimpleStringSearch
Implement a simple string search algorithm using JDK
String.indexOf algorithm |
Constructor and Description |
---|
StringSearch() |
Modifier and Type | Method and Description |
---|---|
Integer |
apply(char[] text,
char[] target,
Integer from)
Run the function with parameters specified.
|
abstract int |
search(char[] text,
char[] target,
int from)
Search a char array in another char array with from index specified
|
static StringSearch |
wrap(Lang.Func3<char[],char[],Integer,Integer> searchLogic) |
public abstract int search(char[] text, char[] target, int from)
Search a char array in another char array with from index specified
text
- the char array to be searchedtarget
- the pattern to be searched across the textfrom
- the from index it shall be non-negative number. If from index is negative number then it starts from 0
; if from
is greater than or equals to the text length then -1
will be returned-1
is returnedpublic final Integer apply(char[] text, char[] target, Integer from) throws NotAppliedException, Lang.Break
Lang.Func3
Run the function with parameters specified.
In case implementing a partial function, it can throw out an NotAppliedException
if the function is not defined for the given parameter(s)
apply
in interface Lang.Func3<char[],char[],Integer,Integer>
text
- argument 1target
- argument 2from
- argument 3NotAppliedException
- if the function doesn’t apply to the parameter(s)Lang.Break
- to short cut collecting operations (fold/reduce) on an container
public static StringSearch wrap(Lang.Func3<char[],char[],Integer,Integer> searchLogic)
Copyright © 2014–2018 OSGL (Open Source General Library). All rights reserved.