forked from mirror/DotRecast
Reverse comparer shenanigans
This commit is contained in:
parent
c989276f5e
commit
b6a1a81fdc
|
@ -25,14 +25,29 @@ namespace DotRecast.Core.Collections
|
|||
{
|
||||
public class RcSortedQueue<T>
|
||||
{
|
||||
private sealed class ReverseComparer : IComparer<T>
|
||||
{
|
||||
private readonly Comparison<T> _comparison;
|
||||
|
||||
public ReverseComparer(Comparison<T> comparison)
|
||||
{
|
||||
_comparison = comparison;
|
||||
}
|
||||
|
||||
public int Compare(T x, T y)
|
||||
{
|
||||
return _comparison(x, y) * -1;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _dirty;
|
||||
private readonly List<T> _items;
|
||||
private readonly Comparer<T> _comparer;
|
||||
private readonly IComparer<T> _comparer;
|
||||
|
||||
public RcSortedQueue(Comparison<T> comp)
|
||||
{
|
||||
_items = new List<T>();
|
||||
_comparer = Comparer<T>.Create((x, y) => comp.Invoke(x, y) * -1);
|
||||
_comparer = new ReverseComparer(comp);
|
||||
}
|
||||
|
||||
public int Count()
|
||||
|
|
Loading…
Reference in New Issue