3 Replies - 603 Views - Last Post: 28 November 2012 - 08:27 PM Rate Topic: -----

#1 RozenKristal  Icon User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 380
  • Joined: 29-September 12

Making custom hash table

Posted 28 November 2012 - 02:07 PM

I understand that in java, I can make a hash function with 1 key, but if I have two keys, how do I manipulate it? I am not sure if my question is too unclear for you guys...


Let say I have a text file line by line.
It line has something like Name#subname

I want to make a hash function with keys as Name and sub name. One Name can have many sub names. So yea... could you give me some ideas on I can work it out? so the value will be put in an array at this location:

a[hashFunc(name, sub name)]

Is This A Good Question/Topic? 0
  • +

Replies To: Making custom hash table

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2831
  • View blog
  • Posts: 11,992
  • Joined: 20-September 08

Re: Making custom hash table

Posted 28 November 2012 - 02:22 PM

You need a 'multimap'
http://commons.apach...s/MultiMap.html
Or make your own (Map<String, List<String>>)
Was This Post Helpful? 1
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,908
  • Joined: 06-March 08

Re: Making custom hash table

Posted 28 November 2012 - 08:07 PM

View PostRozenKristal, on 28 November 2012 - 05:07 PM, said:

I understand that in java, I can make a hash function with 1 key, but if I have two keys, how do I manipulate it? I am not sure if my question is too unclear for you guys...

It is not in Java it is an all computer languages and it is actually related to universal mathematics :)/>

This post has been edited by pbl: 28 November 2012 - 08:08 PM
Reason for edit:: typo

Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10804
  • View blog
  • Posts: 40,278
  • Joined: 27-December 08

Re: Making custom hash table

Posted 28 November 2012 - 08:27 PM

cfoley has a good MultiMap Snippet too.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1