• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

whats a hash map???

 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i tried to read in google on it
but its so abscure

is it an array
is it a linked list
is it a stack??
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is a Map.

From the API for java.util.Map:

An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value.



Then we need the concept of a hash function (from wikipedia):

(turns) some kind of data into a relatively small integer, that may serve as an index into an array. The values returned by a hash function are called hash values, hash codes, hash sums, or simply hashes.



In a Map we store values against a key. In a HashMap, the key is based on the hash code for the object passed in. This provides a faster way to write and retrieve objects from the associated Map.

There are a few tricks to HashMaps, such as efficient sizes and providing effective hashing values (by overriding the hashcode method on the Class), but that's a job for another day
 
alex lotel
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok i understood
we take some data put in in some cell in the map and in order
to use that data we need the key for it

so how do use this command
equals(Object o)

is it like whith objects t.equals(x);
because there could be many objects in the map "t"
i am puzzled

how do we exctract a certain data from a certain location??

i dont know how to understand the definition for this command
hashCode()-Returns the hash code value for this map ??
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A Map is a bit like a telephone book. You put in a name and get out a number. If you put("donaldth smithts", 56789) it will record your phone number a 56789. If you write get("donaldth smithts") it will give 56789.
If you write put("donaldth smithts", 67890) it will change your phone number to 67890 and forget about 56789.
 
alex lotel
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so how does this command go

equals(Object o)
 
Campbell Ritchie
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like this.
 
reply
    Bookmark Topic Watch Topic
  • New Topic