Results 1 to 4 of 4
  1. #1
    Al-Hinai is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Red face Interaction between more than one hashmap

    Hi ,,

    I have three hash maps [host-delivery-predicatability, contact-duration, and contact-counter]
    everyone of them store host-id in their key set. But in the value lists:
    delivery-predicatability hash map store delivery-predicatability value
    contact-duration hash map store contact duration of that each host
    contact-counter hash map store contact counter

    In the following method:
    /**
    * Updates delivery predictions for a host.
    * <CODE>P(a,b) = P(a,b)_old + (1 - P(a,b)_old) * P_INIT</CODE>
    * @param host The host we just met
    */
    private void updateDeliveryPredFor(DTNHost host) {
    double oldValue = getPredFor(host);
    System.out.println("old delivery" + oldValue);
    double newValue = oldValue + (1 - oldValue) * P_INIT ;
    System.out.println("new delivery" + newValue);
    preds.put(host, newValue);
    System.out.println("pred map" + preds);
    }

    I want to use the host-id of delivery-predicatability hash map to get delivery-predicatability for a host and I want to use the key value of that host-id to get the matching detail of that host-id from the other two hash maps contact-duration and contact-counter. How can I do so?
    r

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Interaction between more than one hashmap

    Why not create a class that ties all the information together with four fields representing: host-id, host-delivery-predicatability, contact-duration, and contact-counter? Then you can have one HashMap that maps host-id's with objects of this new class.

  3. #3
    Al-Hinai is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default Re: Interaction between more than one hashmap

    Quote Originally Posted by ;274375
    Why not create a class that ties all the information together with four fields representing: host-id, host-delivery-predicatability, contact-duration, and contact-counter? Then you can have one HashMap that maps host-id's with objects of this new class.
    Thanks Fubarable for your replay. But how can I tie them together in the new class?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Interaction between more than one hashmap

    Quote Originally Posted by Al-Hinai View Post
    Thanks Fubarable for your replay. But how can I tie them together in the new class?
    Please have a look at the Java tutorials: The Really Big Index. Check out the introductory chapters and the "Classes and Objects" chapters.

Similar Threads

  1. want help about ArrayList and interaction
    By chmo in forum New To Java
    Replies: 2
    Last Post: 11-03-2010, 02:45 PM
  2. GUI interaction
    By Glyph in forum New To Java
    Replies: 6
    Last Post: 10-19-2010, 08:43 PM
  3. Java interaction
    By satimis in forum New To Java
    Replies: 4
    Last Post: 06-30-2010, 06:14 PM
  4. Replies: 7
    Last Post: 12-08-2009, 08:17 PM
  5. program interaction possible?
    By Pierced1 in forum Advanced Java
    Replies: 3
    Last Post: 02-19-2009, 01:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •