Re: Case Insensitive Hash but still preserve cases of original keys [message #89004 is a reply to message #89002] |
Mon, 14 July 2014 00:02   |
SonicKenking
Messages: 51 Registered: October 2010
|
Member |
|
|
On Monday, July 14, 2014 4:53:53 PM UTC+10, Fabien wrote:
> Hi,
>
>
>
> On 14.07.2014 08:24, SonicKenking wrote:
>
>> I tried to implement a special Hash object with following features
>
>> 1. Keys are of String type
>
>> 2. Keys should be case insensitive
>
>> 3. The original cases of keys should be preserved and reported when the keys() method is called.
>
>
>
> this sounds like a dictionary to me:
>
>
>
> IDL> h = dictionary()
>
> IDL> h['X'] = 42
>
> IDL> print, h.keys()
>
> X
>
> IDL> print, h['x'], h['X']
>
> 42 42
>
> IDL> print, h.haskey('x'), h.haskey('X')
>
> 1 1
>
> IDL> h['x'] = 1337
>
> IDL> print, h['x'], h['X'] ; output 1337, 1337
>
> 1337 1337
>
> IDL> print, h.keys()
>
> x
>
>
>
> Cheers,
>
>
>
> Fabien
Hi Fabien,
Thanks for the reply. Unfortunately, Dictionary is not the solution in this case. Because the keys do not necessarily conform the naming rules of IDL variables, e.g. a key with white spaces "Some Key " or non-alphanumeric letter "<Key>".
|
|
|