Map Module usage ?

BlitzMax Forums/BlitzMax Programming/Map Module usage ?

bradford6(Posted 2006) [#1]
What is the purpose of the Map module in BlitzMax? What would you typically use this for?

I know what a hash table/dictionary is and that a good hash function is fast but I can't understand what such a key/value Map would be used for in game programming.


North(Posted 2006) [#2]
Maybe an inventory System?

well just about everywhere you benefit from key/value pairs in your game logic you can just use this.

I would also be interested if there are common applications for maps.


FlameDuck(Posted 2006) [#3]
What would you typically use this for?
Mapping stuff. Maps are usually used as associative arrays when you have one type of information, you need linked to some other type of information. In this case it could be a particular game object which is mapped to it's corresponing Image or Sprite object.


bradford6(Posted 2006) [#4]
thanks for the replies. Somewhat Helpful.

perhaps a more concrete example since I am a bit dense :)

assume an instance of Type Tentity called spaceship...
spaceship.image 

holds a reference to the Timage bitmap

why would i want to use key/value pair?


SculptureOfSoul(Posted 2006) [#5]
I would say Maps are most useful when you use them in place of a list that you are going to be searching for specific values often.

I.e. A simple chat server might store the clients as a Socket,Name pair.

Now let's say private messages are allowed, and the server needs to search the current users (the map) for the name of the specified message recipient. If there were a lot of users on, searching the map O(log n) time, is much faster than cycling through a giant list.