"in" everywhere

Daniel Gibson metalcaedes at gmail.com
Thu Oct 7 07:09:17 PDT 2010


Steven Schveighoffer schrieb:
> On Thu, 07 Oct 2010 07:54:14 -0400, atommixz <atommixz at gmail.com> wrote:
> 
>> It would be nice if it were possible to use the "in" expression wherever
>> possible. Now it is only implemented for associative. arrays. (Weird).
>> Examples of how this could be used:
>> - Find string in string
>> - Search for a character in a string
>> - Search for an item in the array, array of characters, array of strings,
>> tuples, enum, structure
>> - what else?
> 
> This has been suggested before.  The problem is that 'in' is generally 
> considered to be a fast operation (< O(n)) so linear search is out.
> 
> -Steve

Is it?
I wouldn't expect it to be < O(n) on a regular array, but it'd still be 
convenient to have instead of iterating over the array and comparing the 
contents yourself.

Cheers,
- Daniel


More information about the Digitalmars-d mailing list