• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

whats a hash map???

 
alex lotel
Ranch Hand
Posts: 191
  • 0
  • Mark post as helpful
  • send pies
  • 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??
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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 ??
 
Campbell Ritchie
Sheriff
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so how does this command go

equals(Object o)
 
Campbell Ritchie
Sheriff
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like this.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic