What is a Map/Table? How is it Implemented?

This is a discussion on What is a Map/Table? How is it Implemented? within the C++ Programming forums, part of the General Programming Boards category; Hello, I would like to know What a Map/Table is? Im sure its just a way to organize data to ...

What is a Map/Table? How is it Implemented?

Hello, I would like to know What a Map/Table is? Im sure its just a way to organize data to look up. Like A Regular table and map would be. But I dont know how its implemented in code. Can Someone explain to me what it is in better terms, and Show me an example of a simple one implemented in Code? Thanks

Notice in the output below that the map container automatically sorts its entries according to the key value regardless of the order in which they were inserted into the map. I.e. Apple comes before Banana which comes before Kiwi which comes before Pear:

Code:

Welcome to Bob's Produce Market
Available fruits and their prices:
Apple costs 0.89/lb.
Banana costs 0.59/lb.
Kiwi costs 1.19/lb.
Pear costs 0.66/lb.
Enter in a fruit to search for: Banana
That fruit costs 0.59/lb.
Enter in a fruit to search for: Pear
That fruit costs 0.66/lb.
Enter in a fruit to search for: Apple
That fruit costs 0.89/lb.
Enter in a fruit to search for: blah
Sorry, we do not have that fruit in stock.
Enter in a fruit to search for:
Goodbye!

"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens

Sake is more in the direction I wanted. The Standard library Map isnt what I was looking for. I was meaning to create my own map, not use someone elses. But thank you Hk. Sake the Information you gave me is going to take me a while to get and read. Its a little complex from what I seen. A Binary Tree is a map then? Also I have another Question, How are the values in the Hex base Number system maped to the Values they should be? Like A is 10 and B is 11. But in ASCI ITs not 10 or 11. How Does THe compilers and stuff know It is 10 or 11. I sthere a map it uses to check it or something? What other data structures are used in making maps? Thanks for the replies

>>A Binary Tree is a map then?
A map is an abstract concept of a collection of items that are accessed by a key. It just happens that a binary search tree is a very close match to that concept without any tweaking. If you wanted you could implement a map as a hash table, or a simple array.

>>How are the values in the Hex base Number system maped to the Values they should be?
It's all binary.

>>I sthere a map it uses to check it or something?
That's totally up to the system, but it could be implemented that way.