1
0
mirror of synced 2024-12-14 08:32:58 +01:00
OpenTaiko/TJAPlayer3/Songs/C曲リストノードComparers/ComparerChain.cs

34 lines
773 B
C#
Raw Normal View History

2021-09-21 00:16:38 +02:00
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;
}
}
}