diff --git a/src/DotRecast.Core/Collections/RcSortedQueue.cs b/src/DotRecast.Core/Collections/RcSortedQueue.cs index 0c06aad..f5c817e 100644 --- a/src/DotRecast.Core/Collections/RcSortedQueue.cs +++ b/src/DotRecast.Core/Collections/RcSortedQueue.cs @@ -25,14 +25,29 @@ namespace DotRecast.Core.Collections { public class RcSortedQueue { + private sealed class ReverseComparer : IComparer + { + private readonly Comparison _comparison; + + public ReverseComparer(Comparison comparison) + { + _comparison = comparison; + } + + public int Compare(T x, T y) + { + return _comparison(x, y) * -1; + } + } + private bool _dirty; private readonly List _items; - private readonly Comparer _comparer; + private readonly IComparer _comparer; public RcSortedQueue(Comparison comp) { _items = new List(); - _comparer = Comparer.Create((x, y) => comp.Invoke(x, y) * -1); + _comparer = new ReverseComparer(comp); } public int Count()