Java Map Equal mapEquals(Map fst, Map snd)

Here you can find the source of mapEquals(Map fst, Map snd)

Description

map Equals

License

LGPL

Declaration

public static boolean mapEquals(Map<?, ?> fst, Map<?, ?> snd) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.util.Iterator;
import java.util.Map;

public class Main {
    public static boolean mapEquals(Map<?, ?> fst, Map<?, ?> snd) {
        if (fst != null && snd != null) {
            Iterator<?> ifst = fst.keySet().iterator();
            Iterator<?> isnd = fst.keySet().iterator();
            while (ifst.hasNext() && isnd.hasNext()) {
                if (!ifst.next().equals(isnd.next()))
                    return false;
            }//  ww  w.j av  a  2  s.c  om

            if (!ifst.hasNext() && !isnd.hasNext()) {
                return true;
            }
        } else if (fst == null && snd == null) {
            return true;
        }
        return false;
    }
}

Related

  1. mapEquals(Map map1, Map map2)
  2. mapEquals(Map map1, Map map2)
  3. mapEquals(Map a, Object b)
  4. mapEquals(Map leftMap, Map rightMap)