Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean containsCount(Vector<?> vec1, Vector<?> vec2){
- HashMap<Object, Integer> vec1count = new HashMap<Object, Integer>();
- HashMap<Object, Integer> vec2count = new HashMap<Object, Integer>();
- for(Object o : vec1){
- if(vec1count.containsKey(o)){
- vec1count.put(o, vec1count.get(o).intValue()+1);
- }else{
- vec1count.put(o, 1);
- }
- }
- for(Object o : vec2){
- if(vec2count.containsKey(o)){
- vec2count.put(o, vec2count.get(o).intValue()+1);
- }else{
- vec2count.put(o, 1);
- }
- }
- Iterator<Object> vec1objects = vec1count.keySet().iterator();
- while(vec1objects.hasNext()){
- Object o = vec1objects.next();
- if(vec2count.containsKey(o)){
- if(vec2count.get(o)!=vec1count.get(o)){
- return false;
- }
- }else{
- return false;
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment