Raised This Month: $51 Target: $400
 12% 

StringMapSnapshot.GetKey gives invalid keys


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xerox8521
Senior Member
Join Date: Sep 2011
Old 06-14-2017 , 14:58   StringMapSnapshot.GetKey gives invalid keys
Reply With Quote #1

I've created a StringMap which has a set key and a value now if i want to find a key based on an index it gives me the wrong value. Seems that the snapshot doesn't save the key / value in the same order as the StringMap has been filled with.

Eg:

Lets say first entry of the StringMap is c1m1_hotel and the value is 0

If i create a snapshot of the StringMap and then use

PHP Code:
snapshot.GetKey(0buffersizeof(buffer)); 
it shows c1m3_mall instead of c1m1_hotel.

So the question is that intended behaviour and how could this be fixed.

Last edited by xerox8521; 06-14-2017 at 14:59.
xerox8521 is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 06-14-2017 , 16:58   Re: StringMapSnapshot.GetKey gives invalid keys
Reply With Quote #2

StringMap isn't an ordered data structure. It just contains a set of pairs of keys and values. The snapshot you take provides you the keys in no particular order.

If you want to keep things in an order, use an ArrayList, probably.
Fyren is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 06-14-2017 , 23:35   Re: StringMapSnapshot.GetKey gives invalid keys
Reply With Quote #3

ah okay never had to use StringMap before. Will use an ArrayList then. Thanks

Last edited by xerox8521; 06-14-2017 at 23:36.
xerox8521 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:57.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode