CSC/ECE 517 Fall 2007/wiki1 1 aman: Difference between revisions
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
'''Comparison of HashMaps in Java vs hashes in Ruby''' | '''Comparison of HashMaps in Java vs hashes in Ruby''' | ||
'''Map''' : A map is any object which stores associations between keys and their corresponding values, in which both keys and the values are objects. The key is unique , however the values may not necessarily be unique. | '''Map''' : A map is any object which stores associations between keys and their corresponding values, in which both keys and the values are objects. The key is unique , however the values may not necessarily be unique. The key, is used to retrieve a value from the map at a later stage after having had stored the values. | ||
'''HashMaps in java''' : In java | '''HashMaps in java''' : In java an AbstractMap class may implement the Map Interface, which maps unique keys to values. The HashMap Class extends this AbstractMap and uses a hash table to store the map. Maps in general do not implement the Iterable interface. Hence iterations through a map are not possible using a for loop and also it is not possible to obtain an iterator to a map. To implement the iteration feature , a collection view of the map for example a set needs to be used . | ||
'''Hashes in ruby''' | '''Hashes in ruby''' |
Revision as of 02:40, 12 September 2007
Comparison of HashMaps in Java vs hashes in Ruby
Map : A map is any object which stores associations between keys and their corresponding values, in which both keys and the values are objects. The key is unique , however the values may not necessarily be unique. The key, is used to retrieve a value from the map at a later stage after having had stored the values.
HashMaps in java : In java an AbstractMap class may implement the Map Interface, which maps unique keys to values. The HashMap Class extends this AbstractMap and uses a hash table to store the map. Maps in general do not implement the Iterable interface. Hence iterations through a map are not possible using a for loop and also it is not possible to obtain an iterator to a map. To implement the iteration feature , a collection view of the map for example a set needs to be used .
Hashes in ruby