Test for element in array

BCS BCS at pathlink.com
Fri Jul 14 09:31:46 PDT 2006


Andrei Khropov wrote:
> Ivan Senji wrote:
> 
> 
>>Yeah, some think it is some think it isn't, I think it isn't but it is an old
>>discussion and probably one we will never agree on.
>>
>>IMO:
>>normal arrays store values which are indexed by a key (index)
>>associative arrays store keys and the value is just an additional information
>>about the key.
>>
>>That is only my opinion as some people think that AA's also are about values.
> 
> 
> AA is also often called dictionary or map (in STL for example).
> 
> If you speak about some kind of collection where only value (and its presense
> or absense in the collection) is important it's probably better to call it a
> set.
> 

How about allow void[TYPE]? No values, only keys.

void[char[]] whos;

... // fill whos

if("Bob" in whos) Hire("Bob");
if("Capone" in whos) whos.remove("Capone");
whos["Bubba"];	// add Bubba

auto him = whos["Bubba"];	// can't do that with a void

// ( or

auto him = whos["Bubba"];	// == bool.true
auto who = whos["Capone"];	// == bool.false

// )



More information about the Digitalmars-d-learn mailing list