turt2live

Untitled

Mar 25th, 2012
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1.     public static boolean containsCount(Vector<?> vec1, Vector<?> vec2){
  2.         HashMap<Object, Integer> vec1count = new HashMap<Object, Integer>();
  3.         HashMap<Object, Integer> vec2count = new HashMap<Object, Integer>();
  4.         for(Object o : vec1){
  5.             if(vec1count.containsKey(o)){
  6.                 vec1count.put(o, vec1count.get(o).intValue()+1);
  7.             }else{
  8.                 vec1count.put(o, 1);
  9.             }
  10.         }
  11.         for(Object o : vec2){
  12.             if(vec2count.containsKey(o)){
  13.                 vec2count.put(o, vec2count.get(o).intValue()+1);
  14.             }else{
  15.                 vec2count.put(o, 1);
  16.             }
  17.         }
  18.         Iterator<Object> vec1objects = vec1count.keySet().iterator();
  19.         while(vec1objects.hasNext()){
  20.             Object o = vec1objects.next();
  21.             if(vec2count.containsKey(o)){
  22.                 if(vec2count.get(o)!=vec1count.get(o)){
  23.                     return false;
  24.                 }
  25.             }else{
  26.                 return false;
  27.             }
  28.         }
  29.         return true;
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment