Test for element in array
Carlos Santander
csantander619 at gmail.com
Fri Jul 14 09:46:24 PDT 2006
BCS escribió:
> 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
>
> // )
It was possible some time ago, but it got forbidden. What I've been doing (and I
think others too) is:
char [] [char []] whos;
And set the element to both the key and the value. However, I admit I liked void
[T].
--
Carlos Santander Bernal
More information about the Digitalmars-d-learn
mailing list