Files
KopMap/Assets/NatureManufacture Assets/WorldStreamer/Scritps/Terrain/IntArrayComparer.cs
2025-09-02 18:55:19 +08:00

51 lines
1.3 KiB
C#

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace WorldStreamer2
{
/// <summary>
/// Int array comparer.
/// </summary>
public class IntArrayComparer : IEqualityComparer<int[]>
{
/// <summary>
/// Equals the specified x and y.
/// </summary>
/// <param name="x">The x coordinate.</param>
/// <param name="y">The y coordinate.</param>
public bool Equals(int[] x, int[] y)
{
if (x.Length != y.Length)
{
return false;
}
for (int i = 0; i < x.Length; i++)
{
if (x[i] != y[i])
{
return false;
}
}
return true;
}
/// <summary>
/// Gets the hash code.
/// </summary>
/// <returns>The hash code.</returns>
/// <param name="obj">Object.</param>
public int GetHashCode(int[] obj)
{
int result = 17;
for (int i = 0; i < obj.Length; i++)
{
unchecked
{
result = result * 23 + obj[i];
}
}
return result;
}
}
}