Compares two sets of snaks, given by iterators. The method is optimised
for short lists of snaks, as they are typically found in claims and
references.

@param snaks1
@param snaks2
@return true if the lists are equal
480406
protected boolean isSameSnakSet(Iterator<Snak> snaks1, Iterator<Snak> snaks2) {
		ArrayList<Snak> snakList1 = new ArrayList<>(5);
		while (snaks1.hasNext()) {
			snakList1.add(snaks1.next());
		}

		int snakCount2 = 0;
		while (snaks2.hasNext()) {
			snakCount2++;
			Snak snak2 = snaks2.next();
			boolean found = false;
			for (int i = 0; i < snakList1.size(); i++) {
				if (snak2.equals(snakList1.get(i))) {
					snakList1.set(i, null);
					found = true;
					break;
				}
			}
			if (!found) {
				return false;
			}
		}

		return snakCount2 == snakList1.size();
	}
180103
@Override
  public int compare(String s1, String s2) {
    if (s1 == s2) { // NOSONAR false-positive: Compare Objects With Equals
      return 0;
    }
    int h1 = s1.hashCode();
    int h2 = s2.hashCode();
    if (h1 < h2) {
      return -1;
    } else if (h1 > h2) {
      return 1;
    } else {
      return s1.compareTo(s2);
    }
  }
240258
public static boolean keyMatch(String key1, String key2) {
        int i = key2.indexOf('*');
        if (i == -1) {
            return key1.equals(key2);
        }

        if (key1.length() > i) {
            return key1.substring(0, i).equals(key2.substring(0, i));
        }
        return key1.equals(key2.substring(0, i));
    }
976874
public static <E> boolean intersects(Set<E> s1, Set<E> s2) {
    // loop over whichever set is smaller
    if (s1.size() < s2.size()) {
      for (E element1 : s1) {
        if (s2.contains(element1)) {
          return true;
        }
      }
    } else {
      for (E element2 : s2) {
        if (s1.contains(element2)) {
          return true;
        }
      }
    }
    
    return false;
  }
344567
public static boolean compareStrings(String s1, String s2) {
        if (s1 == s2)
            return true;
        if (s1 != null && s2 != null && s1.equals(s2))
            return true;
        return false;
    }
500563
public static boolean compareQNameLists(List<QName> list1, List<QName> list2) {
        if (list1 == list2)
            return true;
        if (list1 == null || list2 == null)
            return false;
        if (list1.size() != list2.size())
            return false;

        for (int i = 0; i < list1.size(); i++) {
            if (!compareQNames(list1.get(i), list2.get(i)))
                return false;
        }

        return true;
    }
817110
@Override
  public int compare(S solution1, S solution2) {
    int result = rankComparator.compare(solution1, solution2) ;
    if (result == 0) {
      result = NewcrowdingDistanceComparator.compare(solution1, solution2);
    }

    return result;
  }
1040855
public static boolean compareStringLists(List<String> list1, List<String> list2) {
        if (list1 == null && list2 == null)
            return true;
        if (list1 == null || list2 == null)
            return false;
        if (list1.size() != list2.size())
            return false;
        for (int i = 0; i < list1.size(); i++) {
            if (!compareStrings(list1.get(i), list2.get(i))) {
                return false;
            }
        }

        return true;
    }
774263
public static boolean sameMembersOrdered(View v1, View v2) {
        return Arrays.equals(v1.getMembersRaw(), v2.getMembersRaw());
    }
383448
def dicts_equal(d1, d2):
  

  # check for different sizes
  if len(d1) != len(d2):
    return False
  # check for different keys
  for k in d1:
    if k not in d2:
      return False
  for k in d2:
    if k not in d1:
      return False

  # compare each element in dict
  for k in d1:
    if type(d1[k]) != type(d2[k]):
      # different value types
      return False

    # lists
    elif isinstance(d1[k], list):
      if not (sorted(d1[k]) == sorted(d2[k])):
        return False

    # nested dicts
    elif isinstance(d1[k], dict):
      if not dicts_equal(d1[k], d2[k]):
        return False

    # primitives
    else:
      if d1[k] != d2[k]:
        return False

  return True
1263591
public static String[] difference(final String[] list1, final String[] list2) {
        HashSet<String> set = new HashSet<String>();
        HashSet<String> set1 = new HashSet<String>(Arrays.asList(list1));
        HashSet<String> set2 = new HashSet<String>(Arrays.asList(list2));
        for (final String s : list1) {
            if (!set2.contains(s)) {
                set.add(s);
            }
        }
        for (final String s : list2) {
            if (!set1.contains(s)) {
                set.add(s);
            }
        }
        return set.toArray(new String[set.size()]);
    }
894041
static boolean hasMatchingToStringPair(Iterable<?> items1, Iterable<?> items2) {
    if (isEmpty(items1) || isEmpty(items2)) {
      return false; // Bail early to avoid calling hashCode() on the elements unnecessarily.
    }
    return !retainMatchingToString(items1, items2).isEmpty();
  }
744535
public static boolean varInsnEqual(VarInsnNode insn1, VarInsnNode insn2)
	{
		if (insn1.var == -1 || insn2.var == -1)
			return true;

		return insn1.var == insn2.var;
	}
339897
public static <T> int compare(IntStream s1, IntStream s2, IntBinaryOperator comp)
    {
        PrimitiveIterator.OfInt os1 = s1.iterator();
        PrimitiveIterator.OfInt os2 = s2.iterator();
        while (os1.hasNext() && os2.hasNext())
        {
            int n1 = os1.next();
            int n2 = os2.next();
            int c;
            if (comp == null)
            {
                c = n1 - n2;
            }
            else
            {
                c = comp.applyAsInt(n1, n2);
            }
            if (c != 0)
            {
                return c;
            }
        }
        boolean hn1 = os1.hasNext();
        boolean hn2 = os2.hasNext();
        if (hn1 == hn2)
        {
            return 0;
        }
        if (hn1)
        {
            return 1;
        }
        else
        {
            return -1;
        }
    }
460657
public List<Lock> lockAll(Object key1, Object key2) {
        Lock lock1 = this.locks.get(key1);
        Lock lock2 = this.locks.get(key2);

        int diff = lock1.hashCode() - lock2.hashCode();
        if (diff == 0 && lock1 != lock2) {
            diff = this.indexOf(lock1) - this.indexOf(lock2);
            assert diff != 0;
        }

        List<Lock> locks = diff > 0 ?
                           ImmutableList.of(lock2, lock1) :
                           ImmutableList.of(lock1, lock2);

        for (int i = 0; i < locks.size(); i++) {
            locks.get(i).lock();
        }

        return locks;
    }
288182
protected boolean equivalentClaims(Claim claim1, Claim claim2) {
		return claim1.getMainSnak().equals(claim2.getMainSnak())
				&& isSameSnakSet(claim1.getAllQualifiers(),
						claim2.getAllQualifiers());
	}
323197
public static boolean shapeEquals(int[] shape1, int[] shape2) {
        if (isColumnVectorShape(shape1) && isColumnVectorShape(shape2)) {
            return Arrays.equals(shape1, shape2);
        }

        if (isRowVectorShape(shape1) && isRowVectorShape(shape2)) {
            int[] shape1Comp = squeeze(shape1);
            int[] shape2Comp = squeeze(shape2);
            return Arrays.equals(shape1Comp, shape2Comp);
        }

        //scalars
        if(shape1.length == 0 || shape2.length == 0) {
            if(shape1.length == 0 && shapeIsScalar(shape2)) {
                return true;
            }

            if(shape2.length == 0 && shapeIsScalar(shape1)) {
                return true;
            }
        }


        shape1 = squeeze(shape1);
        shape2 = squeeze(shape2);

        return scalarEquals(shape1, shape2) || Arrays.equals(shape1, shape2);
    }