Posted By

alexedy on 02/26/13


Tagged

tree map optimization interclasation


Versions (?)

TreeMap search


 / Published in: Java
 

Search objects from one map in another, as optimum as possible.

  1. long base = -1;
  2. for(Map.Entry<Long, Obj1> k : m1.entrySet()){
  3. long idk = k.getKey();
  4. Iterator<Map.Entry<Long,Obj2>> it = m2.entrySet().iterator();
  5. while(it.hasNext()){
  6. Map.Entry<Long,Obj2> o2 = it.next();
  7. if(o2.getKey()<base){
  8. continue;
  9. }
  10. if(idk==o2.getKey()){
  11. base = idk;
  12. //TODO: put some logic here
  13. }
  14. }
  15. }

Report this snippet  

You need to login to post a comment.