Results 1 to 4 of 4
- 03-25-2012, 02:59 AM #1
Member
- Join Date
- Mar 2012
- Posts
- 2
- Rep Power
- 0
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
-
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.
- 03-25-2012, 06:05 AM #3
Member
- Join Date
- Mar 2012
- Posts
- 2
- Rep Power
- 0
Re: Interaction between more than one hashmap
Thanks Fubarable for your replay. But how can I tie them together in the new class?
Originally Posted by ;274375
-
Re: Interaction between more than one hashmap
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
-
want help about ArrayList and interaction
By chmo in forum New To JavaReplies: 2Last Post: 11-03-2010, 01:45 PM -
GUI interaction
By Glyph in forum New To JavaReplies: 6Last Post: 10-19-2010, 07:43 PM -
Java interaction
By satimis in forum New To JavaReplies: 4Last Post: 06-30-2010, 05:14 PM -
How to create a new HashMap from a HashMap entries of other methods
By pandeyalok in forum Advanced JavaReplies: 7Last Post: 12-08-2009, 07:17 PM -
program interaction possible?
By Pierced1 in forum Advanced JavaReplies: 3Last Post: 02-19-2009, 12:54 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks