mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2026-04-22 01:45:55 +08:00
fixes
This commit is contained in:
parent
8472280d4b
commit
856682b28e
@ -1086,7 +1086,7 @@ namespace DCFApixels.DragonECS.Core.Internal
|
|||||||
[Il2CppSetOption(Option.NullChecks, false)]
|
[Il2CppSetOption(Option.NullChecks, false)]
|
||||||
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
||||||
#endif
|
#endif
|
||||||
internal readonly struct IncCountComparer : IStructComparer<int>
|
internal readonly struct IncCountComparer : IComparer<int>
|
||||||
{
|
{
|
||||||
public readonly EcsWorld.PoolSlot[] counts;
|
public readonly EcsWorld.PoolSlot[] counts;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@ -1105,7 +1105,7 @@ namespace DCFApixels.DragonECS.Core.Internal
|
|||||||
[Il2CppSetOption(Option.NullChecks, false)]
|
[Il2CppSetOption(Option.NullChecks, false)]
|
||||||
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
||||||
#endif
|
#endif
|
||||||
internal readonly struct ExcCountComparer : IStructComparer<int>
|
internal readonly struct ExcCountComparer : IComparer<int>
|
||||||
{
|
{
|
||||||
public readonly EcsWorld.PoolSlot[] counts;
|
public readonly EcsWorld.PoolSlot[] counts;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
|||||||
@ -12,6 +12,38 @@ using Unity.IL2CPP.CompilerServices;
|
|||||||
|
|
||||||
namespace DCFApixels.DragonECS.Core.Internal
|
namespace DCFApixels.DragonECS.Core.Internal
|
||||||
{
|
{
|
||||||
|
#if ENABLE_IL2CPP
|
||||||
|
[Il2CppSetOption(Option.NullChecks, false)]
|
||||||
|
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
||||||
|
#endif
|
||||||
|
internal static class ArraySortUtility
|
||||||
|
{
|
||||||
|
internal static StructComparison<T> ToStruct<T>(this Comparison<T> self)
|
||||||
|
{
|
||||||
|
return new StructComparison<T>(self);
|
||||||
|
}
|
||||||
|
public static void Sort<T>(Span<T> span, Comparison<T> comparison)
|
||||||
|
{
|
||||||
|
var c = comparison.ToStruct();
|
||||||
|
ArraySortUtility<T, StructComparison<T>>.Sort(span, ref c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if ENABLE_IL2CPP
|
||||||
|
[Il2CppSetOption(Option.NullChecks, false)]
|
||||||
|
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
||||||
|
#endif
|
||||||
|
internal readonly struct StructComparison<T> : IComparer<T>
|
||||||
|
{
|
||||||
|
public readonly Comparison<T> Comparison;
|
||||||
|
public StructComparison(Comparison<T> comparison)
|
||||||
|
{
|
||||||
|
Comparison = comparison;
|
||||||
|
}
|
||||||
|
public int Compare(T x, T y)
|
||||||
|
{
|
||||||
|
return Comparison(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
// a > b = return > 0
|
// a > b = return > 0
|
||||||
// int Compare(T a, T b);
|
// int Compare(T a, T b);
|
||||||
|
|
||||||
|
|||||||
@ -281,29 +281,4 @@ namespace DCFApixels.DragonECS.Core.Internal
|
|||||||
return $"{name}({range.Count()}) {{{string.Join(", ", range.Select(o => o.ToString()))}}})";
|
return $"{name}({range.Count()}) {{{string.Join(", ", range.Select(o => o.ToString()))}}})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static class SpanUtility
|
|
||||||
{
|
|
||||||
internal static StructComparison<T> ToStruct<T>(this Comparison<T> self)
|
|
||||||
{
|
|
||||||
return new StructComparison<T>(self);
|
|
||||||
}
|
|
||||||
public static void Sort<T>(Span<T> span, Comparison<T> comparison)
|
|
||||||
{
|
|
||||||
var c = comparison.ToStruct();
|
|
||||||
ArraySortUtility<T, StructComparison<T>>.Sort(span, ref c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
internal readonly struct StructComparison<T> : IComparer<T>
|
|
||||||
{
|
|
||||||
public readonly Comparison<T> Comparison;
|
|
||||||
public StructComparison(Comparison<T> comparison)
|
|
||||||
{
|
|
||||||
Comparison = comparison;
|
|
||||||
}
|
|
||||||
public int Compare(T x, T y)
|
|
||||||
{
|
|
||||||
return Comparison(x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user