Map.mod

BlitzMax Forums/BlitzMax Programming/Map.mod

teamonkey(Posted 2005) [#1]
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.


eni(Posted 2005) [#2]
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).


Robert(Posted 2005) [#3]
Ditto - it is very handy.


tonyg(Posted 2005) [#4]
Might be silly question but what do/can you use it for?


teamonkey(Posted 2005) [#5]
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 :)


Bot Builder(Posted 2005) [#6]
Could use it for a dictionary if its optimized with hash tables..


Robert(Posted 2005) [#7]
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.


Haramanai(Posted 2006) [#8]
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?


tonyg(Posted 2006) [#9]
This is probably the best so far.
There is some stuff in the wiki...
map


Haramanai(Posted 2006) [#10]
Thanks... That's good.