Page 1 of 1
FindMapElement and #PB_String_NoCase
Posted: Sun May 16, 2010 5:01 am
by Seymour Clufley
I think this would be useful.
Re: FindMapElement and #PB_String_NoCase
Posted: Sun May 16, 2010 7:50 pm
by Trond
Why don't you make all elements lowercase and then use findmapelement(map(), lcase(string))?
Re: FindMapElement and #PB_String_NoCase
Posted: Sun May 16, 2010 9:16 pm
by Seymour Clufley
Trond wrote:Why don't you make all elements lowercase and then use findmapelement(map(), lcase(string))?
Well yes, that would be one solution. But I think #PB_String_NoCase would be easier to code, and would bring that command in line with FindString().
Re: FindMapElement and #PB_String_NoCase
Posted: Sun May 16, 2010 10:20 pm
by STARGĂ…TE
but the problem ist:
Code: Select all
NewMap Test.i()
Test("Case") = 1
Test("casE") = 2
Debug Test("Case")
Debug Test("casE")
FindMapElement(Test(), "case", #PB_String_NoCase)
which element is now to be found?
Case ?
casE ?
or none Element, because it is not unique ?
Re: FindMapElement and #PB_String_NoCase
Posted: Mon May 17, 2010 1:40 am
by Seymour Clufley
That would be for Fred/Freak to decide.
I would suggest the first element that is found. If the programmer is using #PB_String_NoCase he should be aware if there could be multiple matching elements in the map and it's a risk he can choose to take.
Re: FindMapElement and #PB_String_NoCase
Posted: Mon May 17, 2010 9:17 am
by Rescator
A #PB_String_NoCase would also slow down the hash map a lot, in fact it might be almost as fast to just use a list I suspect.