1
0
mirror of synced 2024-12-01 02:27:21 +01:00
OpenTaiko/TJAPlayer3/Songs/C曲リストノードComparers/ComparerChain.cs
2021-09-21 00:16:38 +02:00

34 lines
773 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections.Generic;
namespace TJAPlayer3.C曲リストードComparers
{
internal sealed class ComparerChain<T> : IComparer<T> where T : class
{
private readonly IComparer<T>[] _comparers;
public ComparerChain(params IComparer<T>[] comparers)
{
_comparers = comparers;
}
public int Compare(T x, T y)
{
if (ReferenceEquals(x, y))
{
return 0;
}
for (int i = 0; i < _comparers.Length; i++)
{
var result = _comparers[i].Compare(x, y);
if (result != 0)
{
return result;
}
}
return 0;
}
}
}