Dumping key/value pairs from TMap

BlitzMax Forums/BlitzMax Programming/Dumping key/value pairs from TMap

ozak(Posted 2006) [#1]
Anyone? I've tried anything.
The iterators work fine for dumping just the keys, but otherwise I'm lost :)

Thanks in advance


Warren(Posted 2006) [#2]
If you've got the keys, can't you just look up the values?


tonyg(Posted 2006) [#3]
What do you mean by 'dumping'?


ozak(Posted 2006) [#4]
I mean retrieving the keys in a list.
But yes I could look up the values, but in other languages you can get a value/pair struct for each. Oh well :)


klepto2(Posted 2006) [#5]
Maybe this helps you:




marksibly(Posted 2006) [#6]
Hi,

Yes, the 'new' TMap doesn't have a way of traversing Key/Value pairs yet, as I realized today at work!

Will be fixed soon, but in the meantime you're stuck with using ValueForKey() inside a key loop.


Gabriel(Posted 2006) [#7]
Any idea when we might expect this? Or a suggestion of how I could fix it myself by extending TMap? I've hit a bit of a dead end in my work because of this, and I can't see any way around it.

EDIT: Actually, forget extending it. For now, if I could just flat copy it lock, stock to a new module and make some changes, it would get me through until it's fixed.


SculptureOfSoul(Posted 2006) [#8]
Here's an example I whipped up while trying to figure out how to do this myself. I apologize for the ultra sloppy code




Gabriel(Posted 2006) [#9]
Ah, thanks for the example and explanation. We're safe using fields prefixed with _ are we? I thought perhaps they were subject to change or something.


Dreamora(Posted 2006) [#10]
if fields with _ would be a problem, many 3rd party stuff would get in serious trouble as most (including me) use it to mark something as private :)


Gabriel(Posted 2006) [#11]
That was precisely my point. If they're "private", we shouldn't be using them, and they may be subject to change.