<commit_before>// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/**
 * Defines equality relations on collections.
 */
library dart.collection_helper.equality;

import "dart:collection";

const int _HASH_MASK = 0x7fffffff;

/**
 * A generic equality relation on objects.
 */
abstract class Equality<E> {
  const factory Equality() = DefaultEquality;

  /**
   * Compare two elements for being equal.
   *
   * This should be a proper equality relation.
   */
  bool equals(E e1, E e2);

  /**
   * Get a hashcode of an element.
   *
   * The hashcode should be compatible with [equals], so that if
   * `equals(a, b)` then `hash(a) == hash(b)`.
   */
  int hash(E e);

  /**
   * Test whether an object is a valid argument to [equals] and [hash].
   *
   * Some implementations may be restricted to only work on specific types
   * of objects.
   */
  bool isValidKey(Object o);
}

/**
 * Equality of objects that compares only the natural equality of the objects.
 *
 * This equality uses the objects' own [Object.==] and [Object.hashCode] for
 * the equality.
 */
class DefaultEquality implements Equality<Object> {
  const DefaultEquality();
  bool equals(Object e1, Object e2) => e1 == e2;
  int hash(Object e) => e.hashCode;
  bool isValidKey(Object o) => true;
}

/**
 * Equality of objects that compares only the identity of the objects.
 */
class IdentityEquality implements Equality<Object> {
  const IdentityEquality();
  bool equals(Object e1, Object e2) => identical(e1, e2);
  int hash(Object e) => identityHashCode(e);
  bool isValidKey(Object o) => true;
}

/**
 * Equality on iterables.
 *
 * Two iterables are equal if they have the same elements in the same order.
 */
class IterableEquality<E> implements Equality<Iterable<E>> {
  final Equality<E> _elementEquality;
  const IterableEquality([Equality<E> elementEquality =
                              const DefaultEquality()])
      : _elementEquality = elementEquality;

  bool equals(Iterable<E> elements1, Iterable<E> elements2) {
    if (identical(elements1, elements2)) return true;<commit_msg>Fix equality type problem.<commit_after>// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/**
 * Defines equality relations on collections.
 */
library dart.collection_helper.equality;

import "dart:collection";

const int _HASH_MASK = 0x7fffffff;

/**
 * A generic equality relation on objects.
 */
abstract class Equality<E> {
  const factory Equality() = DefaultEquality;

  /**
   * Compare two elements for being equal.
   *
   * This should be a proper equality relation.
   */
  bool equals(E e1, E e2);

  /**
   * Get a hashcode of an element.
   *
   * The hashcode should be compatible with [equals], so that if
   * `equals(a, b)` then `hash(a) == hash(b)`.
   */
  int hash(E e);

  /**
   * Test whether an object is a valid argument to [equals] and [hash].
   *
   * Some implementations may be restricted to only work on specific types
   * of objects.
   */
  bool isValidKey(Object o);
}

/**
 * Equality of objects that compares only the natural equality of the objects.
 *
 * This equality uses the objects' own [Object.==] and [Object.hashCode] for
 * the equality.
 */
class DefaultEquality implements Equality {
  const DefaultEquality();
  bool equals(Object e1, Object e2) => e1 == e2;
  int hash(Object e) => e.hashCode;
  bool isValidKey(Object o) => true;
}

/**
 * Equality of objects that compares only the identity of the objects.
 */
class IdentityEquality implements Equality {
  const IdentityEquality();
  bool equals(Object e1, Object e2) => identical(e1, e2);
  int hash(Object e) => identityHashCode(e);
  bool isValidKey(Object o) => true;
}

/**
 * Equality on iterables.
 *
 * Two iterables are equal if they have the same elements in the same order.
 */
class IterableEquality<E> implements Equality<Iterable<E>> {
  final Equality<E> _elementEquality;
  const IterableEquality([Equality<E> elementEquality =
                              const DefaultEquality()])
      : _elementEquality = elementEquality;

  bool equals(Iterable<E> elements1, Iterable<E> elements2) {
    if (identical(elements1, elements2)) return true;
{'fraction_non_alphanumeric': 0.10534556027734288, 'fraction_numerical': 0.008946544397226572, 'mean_word_length': 3.4497512437810944, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5203914', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1326, 'n_words': 504}