G gpe Member Licensed User Longtime User Oct 29, 2011 #1 I noticed that in MAP collection the member "indexOf" is missing. Is there a way to find out the index related to the key other than searching among the items? gp
I noticed that in MAP collection the member "indexOf" is missing. Is there a way to find out the index related to the key other than searching among the items? gp
Erel B4X founder Staff member Licensed User Longtime User Oct 30, 2011 #2 You will need to search among the items. The index is usually less important in Maps. The index is only available to allow you to iterate over the items.
You will need to search among the items. The index is usually less important in Maps. The index is only available to allow you to iterate over the items.
G gpe Member Licensed User Longtime User Oct 30, 2011 #3 many thanks, Erel I need to filter an array of strings where the key is inside and build a listview. I'm not so sure, but creating a map using substrings doesn't work properly. This is the reason I wanted to use the index instead of keys. Now I've solved the problem creating two arrays to correlate the indexes.
many thanks, Erel I need to filter an array of strings where the key is inside and build a listview. I'm not so sure, but creating a map using substrings doesn't work properly. This is the reason I wanted to use the index instead of keys. Now I've solved the problem creating two arrays to correlate the indexes.
H Hubert Brandel Active Member Licensed User Longtime User Oct 30, 2011 #4 Is this a bug ? Hi, map keys are unique, this is true and usefull. It works good with numeric keys, but I was confused on this: Code: Dim m As Map m.Initialize m.Put("test","Testwert") m.Put("TEST","New Value") Log("Test=" & m.Get("Test") ) ' => null Log("test=" & m.Get("test") ) ' => Testwert Log("TEST=" & m.Get("Test") ) ' => null The seconds call - m.Put("TEST","New Value") - was ignored. m.GET is case sensitive, thats not usefull. PUT should build the key with key.tolower() GET should build the key with key.equalignorecases() Am I right ? Does SQL needs fieldnames in lower ?
Is this a bug ? Hi, map keys are unique, this is true and usefull. It works good with numeric keys, but I was confused on this: Code: Dim m As Map m.Initialize m.Put("test","Testwert") m.Put("TEST","New Value") Log("Test=" & m.Get("Test") ) ' => null Log("test=" & m.Get("test") ) ' => Testwert Log("TEST=" & m.Get("Test") ) ' => null The seconds call - m.Put("TEST","New Value") - was ignored. m.GET is case sensitive, thats not usefull. PUT should build the key with key.tolower() GET should build the key with key.equalignorecases() Am I right ? Does SQL needs fieldnames in lower ?
klaus Expert Licensed User Longtime User Oct 30, 2011 #5 The second Put statement was shurely not ignored! You didn't look at it right: Your last Log should be like this: Code: Log("T[COLOR=Black]EST[/COLOR]"=" & m.Get("T[COLOR=Red]EST[/COLOR]")) Best regards. Last edited: Oct 30, 2011
The second Put statement was shurely not ignored! You didn't look at it right: Your last Log should be like this: Code: Log("T[COLOR=Black]EST[/COLOR]"=" & m.Get("T[COLOR=Red]EST[/COLOR]")) Best regards.
agraham Expert Licensed User Longtime User Oct 30, 2011 #6 Hubert Brandel said: PUT should build the key with key.tolower() GET should build the key with key.equalignorecases() Am I right ? Click to expand... No. A Map can hold any kind of Object for keys and values, not just Strings. A Map just tests for object identity, it knows nothing about what the actual keys and values are. If you are using string you will have to do your own case-conversion if you want case-insensitivity.
Hubert Brandel said: PUT should build the key with key.tolower() GET should build the key with key.equalignorecases() Am I right ? Click to expand... No. A Map can hold any kind of Object for keys and values, not just Strings. A Map just tests for object identity, it knows nothing about what the actual keys and values are. If you are using string you will have to do your own case-conversion if you want case-insensitivity.
Erel B4X founder Staff member Licensed User Longtime User Oct 30, 2011 #7 object identity Click to expand... => object equality.
H Hubert Brandel Active Member Licensed User Longtime User Oct 31, 2011 #8 Hi, @ Klaus, you are right and found my mistake Code: Dim m As Map m.Initialize m.Put("test","Testwert") m.Put("TEST","New Value") Log("Test=" & m.Get("Test") ) ' => null Log("test=" & m.Get("test") ) ' => Testwert Log("TEST=" & m.Get("TEST") ) ' => "New Value" @all I find it very strange to have case sensitive variables and filenames. I can't see any serious reason why linux does it this way. A case insensitive key would be much easier and avoid typing errors.
Hi, @ Klaus, you are right and found my mistake Code: Dim m As Map m.Initialize m.Put("test","Testwert") m.Put("TEST","New Value") Log("Test=" & m.Get("Test") ) ' => null Log("test=" & m.Get("test") ) ' => Testwert Log("TEST=" & m.Get("TEST") ) ' => "New Value" @all I find it very strange to have case sensitive variables and filenames. I can't see any serious reason why linux does it this way. A case insensitive key would be much easier and avoid typing errors.
K kickaha Well-Known Member Licensed User Longtime User Oct 31, 2011 #9 Hubert Brandel said: Hi, @all I find it very strange to have case sensitive variables and filenames. I can't see any serious reason why linux does it this way. A case insensitive key would be much easier and avoid typing errors. Click to expand... Yes but it would not be as flexible (and therefore not as useful).
Hubert Brandel said: Hi, @all I find it very strange to have case sensitive variables and filenames. I can't see any serious reason why linux does it this way. A case insensitive key would be much easier and avoid typing errors. Click to expand... Yes but it would not be as flexible (and therefore not as useful).