java - Iterating through hashmap keys and comparing -


i want iterate through each key of hashmap , compare each key below (so don't compare keys twice). want see slopes perpendicular each other. if product of slopes -1, , arraylists keys.

so far have built map using:

map<double, list<double>> map = new hashmap<double, list<double>>();  for(int = 0; < n; i++) {     for(int j = + 1; j < n; j++) {         if(line[4][i] == line[4][j]) {             double distance = 7.0;   //distance();              list<double> array = (map.containskey(line[4][i])) ? map.get(line[4][i]):new arraylist<double>();             array.add(distance);             map.put(line[4][i], array);              // system.out.println(arrays.aslist(array));             // system.out.println(distance);         }     } } 

and attempt iterate through map with:

iterator<entry<double, list<double>>> = map.entryset().iterator(); while(i.hasnext()) {     entry next = i.next();     i.remove();     for(entry e : map.entryset()) {         system.out.println(next + " " + e);          //error: method parsedouble(string) in type double not applicable arguments (object)         if((double.parsedouble(next.getkey()) * (double.parsedouble(e.getkey()))) == -1)              system.out.println("pair"); //do      } } 

but can't parse object double, , i'm lost how continue. appreciated

to question, use type qualifiers next entry:

map.entry<double, list<double>> next = i.next(); 

and here too:

map.entry<double, list<double>> e : map.entryset() 

then compiler know getkey() return doubles, , allow multiply them each other.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -