a sets implementation

Stephan Diehl stephan.diehl at gmx.net
Wed Feb 7 04:46:39 PST 2007


Frits van Bommel wrote:
> Stephan Diehl wrote:
>> Michiel wrote:
>>> * I would overload the 'in' operator anyway.
>>
>> I tried. But for some reason, the compiler insists on associative 
>> arrays when using the 'in' operator. And when used with associative 
>> arrays, it will test the values, not the keys. (it's just the other 
>> way round in python: the 'in' operator checks for the keys, which 
>> actually does make some sense).
> 
> ??
> I think you're a bit confused here.

yes, that's certainly true.

> When used with associative arrays 
> the 'in' operator definitely tests keys, not values[1]. For associative 
> arrays it may return a pointer to the value, but it checks if the key is 
> in the AA.
[...]
> 
> A note about overloading: If you want to overload the 'in' operator 
> you'll probably want to use opIn_r (so that it's used for "key in set" 
> expressions), not opIn (which would give you "set in key" syntax, which 
> doesn't make much sense).

Ah, yes.
It now works as expected. Thanks a lot



More information about the Digitalmars-d mailing list