We now have a context menu UI for in-game actions, right click on an item to activate Database view has a progress bar (finally!) Data structures for Megacorps and loadouts Towing task complete? needs testing
153 lines
5.5 KiB
C#
153 lines
5.5 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace JM.LinqFaster
|
|
{
|
|
|
|
public static partial class LinqFaster
|
|
{
|
|
|
|
/// <summary>
|
|
/// Determines whether two sequences are equal by comparing the elements by using the
|
|
/// provided comparer or the default equality comparer for their type if none is provided.
|
|
/// </summary>
|
|
/// <param name="first">A sequence to compare to second.</param>
|
|
/// <param name="second">A sequence to compare to first.</param>
|
|
/// <param name="comparer">An optional Comparer to use for the comparison.</param>
|
|
/// <returns>true of the two sources are of equal length and their corresponding
|
|
/// elements are equal according to the equality comparer. Otherwise, false.</returns>
|
|
public static bool SequenceEqualF<T>(T[] first, T[] second, IEqualityComparer<T> comparer = null)
|
|
{
|
|
if (comparer == null)
|
|
{
|
|
comparer = EqualityComparer<T>.Default;
|
|
}
|
|
|
|
if (first == null)
|
|
{
|
|
throw Error.ArgumentNull("first");
|
|
}
|
|
|
|
if (second == null)
|
|
{
|
|
throw Error.ArgumentNull("second");
|
|
}
|
|
|
|
if (first.Length != second.Length) return false;
|
|
|
|
for (int i = 0; i < first.Length; i++)
|
|
{
|
|
if (!comparer.Equals(first[i], second[i])) return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determines whether two sequences are equal by comparing the elements by using the
|
|
/// provided comparer or the default equality comparer for their type if none is provided.
|
|
/// </summary>
|
|
/// <param name="first">A sequence to compare to second.</param>
|
|
/// <param name="second">A sequence to compare to first.</param>
|
|
/// <param name="comparer">An optional Comparer to use for the comparison.</param>
|
|
/// <returns>true of the two sources are of equal length and their corresponding
|
|
/// elements are equal according to the equality comparer. Otherwise, false.</returns>
|
|
public static bool SequenceEqualF<T>(List<T> first, List<T> second, IEqualityComparer<T> comparer = null)
|
|
{
|
|
if (comparer == null)
|
|
{
|
|
comparer = EqualityComparer<T>.Default;
|
|
}
|
|
|
|
if (first == null)
|
|
{
|
|
throw Error.ArgumentNull("first");
|
|
}
|
|
|
|
if (second == null)
|
|
{
|
|
throw Error.ArgumentNull("second");
|
|
}
|
|
|
|
if (first.Count != second.Count) return false;
|
|
|
|
for (int i = 0; i < first.Count; i++)
|
|
{
|
|
if (!comparer.Equals(first[i], second[i])) return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determines whether two sequences are equal by comparing the elements by using the
|
|
/// provided comparer or the default equality comparer for their type if none is provided.
|
|
/// </summary>
|
|
/// <param name="first">A sequence to compare to second.</param>
|
|
/// <param name="second">A sequence to compare to first.</param>
|
|
/// <param name="comparer">An optional Comparer to use for the comparison.</param>
|
|
/// <returns>true of the two sources are of equal length and their corresponding
|
|
/// elements are equal according to the equality comparer. Otherwise, false.</returns>
|
|
public static bool SequenceEqualF<T>(T[] first, List<T> second, IEqualityComparer<T> comparer = null)
|
|
{
|
|
if (comparer == null)
|
|
{
|
|
comparer = EqualityComparer<T>.Default;
|
|
}
|
|
|
|
if (first == null)
|
|
{
|
|
throw Error.ArgumentNull("first");
|
|
}
|
|
|
|
if (second == null)
|
|
{
|
|
throw Error.ArgumentNull("second");
|
|
}
|
|
|
|
if (first.Length != second.Count) return false;
|
|
|
|
for (int i = 0; i < first.Length; i++)
|
|
{
|
|
if (!comparer.Equals(first[i], second[i])) return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determines whether two sequences are equal by comparing the elements by using the
|
|
/// provided comparer or the default equality comparer for their type if none is provided.
|
|
/// </summary>
|
|
/// <param name="first">A sequence to compare to second.</param>
|
|
/// <param name="second">A sequence to compare to first.</param>
|
|
/// <param name="comparer">An optional Comparer to use for the comparison.</param>
|
|
/// <returns>true of the two sources are of equal length and their corresponding
|
|
/// elements are equal according to the equality comparer. Otherwise, false.</returns>
|
|
public static bool SequenceEqualF<T>(List<T> first, T[] second, IEqualityComparer<T> comparer = null)
|
|
{
|
|
if (comparer == null)
|
|
{
|
|
comparer = EqualityComparer<T>.Default;
|
|
}
|
|
|
|
if (first == null)
|
|
{
|
|
throw Error.ArgumentNull("first");
|
|
}
|
|
|
|
if (second == null)
|
|
{
|
|
throw Error.ArgumentNull("second");
|
|
}
|
|
|
|
if (first.Count != second.Length) return false;
|
|
|
|
for (int i = 0; i < first.Count; i++)
|
|
{
|
|
if (!comparer.Equals(first[i], second[i])) return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|