input validation

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Mar 4 12:18:43 PST 2009


bearophile wrote:
> Andrei Alexandrescu:
>> int[] a = [ 1, 2, 3, 4 ];
>> int[] b = [ 2. 3 ];
> 
> I guess you meant:
> 
> int[] b = [ 2, 3 ];
> 
>> find(a, b);
>> find(assumeSorted(a), b);
>> find(a, assumeSorted(b));
>> find(assumeSorted(a), assumeSorted(b));
>> find(a, boyerMooreFinder(b));
> 
> Are you talking about finding the position of a subarray into a bigger array? Then the two useful cases are:
> a.index(b);
> a.indexBoyerMoore(b);
> The other cases aren't common enough, I think.
> 
> Bye,
> bearophile

Binary search is rather common.

As an aside, your use of "index" suggests you return integrals out of 
the function. IMHO that's strongly unrecommended.


Andrei



More information about the Digitalmars-d mailing list