3 public partial class Matcher<TEntity> {
5 public override bool Equals(
object obj) {
6 if(obj == null || obj.GetType() != GetType() ||
7 obj.GetHashCode() != GetHashCode()) {
12 if(!equalIndices(matcher.allOfIndices, _allOfIndices)) {
15 if(!equalIndices(matcher.anyOfIndices, _anyOfIndices)) {
18 if(!equalIndices(matcher.noneOfIndices, _noneOfIndices)) {
25 static bool equalIndices(
int[] i1,
int[] i2) {
26 if((i1 == null) != (i2 == null)) {
32 if(i1.Length != i2.Length) {
36 for (
int i = 0; i < i1.Length; i++) {
48 public override int GetHashCode() {
50 var hash = GetType().GetHashCode();
51 hash = applyHash(hash, _allOfIndices, 3, 53);
52 hash = applyHash(hash, _anyOfIndices, 307, 367);
53 hash = applyHash(hash, _noneOfIndices, 647, 683);
61 static int applyHash(
int hash,
int[] indices,
int i1,
int i2) {
63 for (
int i = 0; i < indices.Length; i++) {
64 hash ^= indices[i] * i1;
66 hash ^= indices.Length * i2;