From fff09986137af74b745d7e65f78f50049b354071 Mon Sep 17 00:00:00 2001 From: wrenge Date: Wed, 13 Nov 2024 09:35:27 +0300 Subject: [PATCH] Pass delegate --- .../Collections/RcSortedQueue.cs | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/DotRecast.Core/Collections/RcSortedQueue.cs b/src/DotRecast.Core/Collections/RcSortedQueue.cs index f5c817e..0fe502d 100644 --- a/src/DotRecast.Core/Collections/RcSortedQueue.cs +++ b/src/DotRecast.Core/Collections/RcSortedQueue.cs @@ -25,29 +25,14 @@ 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 IComparer _comparer; + private readonly Comparison _comparison; public RcSortedQueue(Comparison comp) { _items = new List(); - _comparer = new ReverseComparer(comp); + _comparison = (x, y) => comp(x, y) * -1; } public int Count() @@ -70,7 +55,7 @@ namespace DotRecast.Core.Collections { if (_dirty) { - _items.Sort(_comparer); // reverse + _items.Sort(_comparison); // reverse _dirty = false; } }