using System; using System.Collections.Generic; namespace EcsRx.Events.Collections { public struct CollectionElementChangedEvent : IEquatable> { public int Index; public T OldValue; public T NewValue; public bool Equals(CollectionElementChangedEvent other) { return Index == other.Index && EqualityComparer.Default.Equals(OldValue, other.OldValue) && EqualityComparer.Default.Equals(NewValue, other.NewValue); } public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) {return false;} return obj is CollectionElementChangedEvent other && Equals(other); } public override int GetHashCode() { unchecked { var hashCode = Index; hashCode = (hashCode * 397) ^ EqualityComparer.Default.GetHashCode(OldValue); hashCode = (hashCode * 397) ^ EqualityComparer.Default.GetHashCode(NewValue); return hashCode; } } } }