Map.mod
BlitzMax Forums/BlitzMax Programming/Map.mod
| ||
What's there looks cool. It looks so close to completion, I'm not sure why it wasn't. Just missing a couple of wrapper functions, by the looks. Is it usable? ... [EDIT] Well it certainly seems to work OK. Can't imagine why the wrapper functions haven't been added though. |
| ||
I commented about it not being documented in the bug reports ages ago but heard nothing. It seems perfectly usable to me too (in fact I do use it). |
| ||
Ditto - it is very handy. |
| ||
Might be silly question but what do/can you use it for? |
| ||
Lots of things, but most commonly you set the Key to be a String and point the Value at some object. Then you've got something that resembles an array that uses a String as the element index instead of an integer. Like associative arrays in PHP or Lua. You could use it like this: Local m:TMap = New TMap m.Insert("img1.jpg",LoadImage("img1.jpg")) m.Insert("img2.jpg",LoadImage("img2.jpg")) DrawImage(TImage(m.ValueForKey("img1.jpg")), 100, 100) Not sure why you would want to do that, but you can :) |
| ||
Could use it for a dictionary if its optimized with hash tables.. |
| ||
You can use maps rather like lists, except that they are much, much quicker to search. For example, if you have a list of 1000 strings it would require up to 1000 tests to search the list for a particular string. Because of the way that maps store data, it would only take around 10 or so tests to find a particular string in a 1000 object map. |
| ||
I don't wand to be rude rising this thread from the dead but can some one be more specific about map or do the good work to documented in the wiki? |
| ||
This is probably the best so far. There is some stuff in the wiki... map |
| ||
Thanks... That's good. |