FindMapElement and #PB_String_NoCase
-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
FindMapElement and #PB_String_NoCase
I think this would be useful.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: FindMapElement and #PB_String_NoCase
Why don't you make all elements lowercase and then use findmapelement(map(), lcase(string))?
-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: FindMapElement and #PB_String_NoCase
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().Trond wrote:Why don't you make all elements lowercase and then use findmapelement(map(), lcase(string))?
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: FindMapElement and #PB_String_NoCase
but the problem ist:
which element is now to be found?
Case ?
casE ?
or none Element, because it is not unique ?
Code: Select all
NewMap Test.i()
Test("Case") = 1
Test("casE") = 2
Debug Test("Case")
Debug Test("casE")
FindMapElement(Test(), "case", #PB_String_NoCase)
Case ?
casE ?
or none Element, because it is not unique ?
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: FindMapElement and #PB_String_NoCase
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.
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.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: FindMapElement and #PB_String_NoCase
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.