VCollections.src.org.violetlib.collections.impl.MapEquality Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vcollections Show documentation
Show all versions of vcollections Show documentation
Java Immutable Collections
The newest version!
/*
* Copyright (c) 2023 Alan Snyder.
* All rights reserved.
*
* You may not use, copy or modify this file, except in compliance with the license agreement. For details see
* accompanying license terms.
*/
package org.violetlib.collections.impl;
import org.violetlib.collections.IMap;
import org.violetlib.collections.ISet;
import org.jetbrains.annotations.*;
import org.violetlib.annotations.NoInstances;
/**
*/
public final @NoInstances class MapEquality
{
private MapEquality()
{
throw new AssertionError("MapEquality may not be instantiated");
}
public static boolean isEqual(@NotNull IMap,?> m1, @NotNull IMap,?> m2)
{
if (m1 == m2) {
return true;
}
if (m1.size() != m2.size()) {
return false;
}
ISet> keys1 = m1.keySet();
ISet> keys2 = m2.keySet();
if (!keys1.equals(keys2)) {
return false;
}
IMap