mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-11-14 18:15:55 +08:00
code style refactoring
This commit is contained in:
parent
51a4327358
commit
002894ce9c
@ -229,8 +229,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get { return _isReleased; }
|
get { return _isReleased; }
|
||||||
}
|
}
|
||||||
|
bool ICollection<int>.IsReadOnly { get { return false; } }
|
||||||
bool ICollection<int>.IsReadOnly => throw new NotImplementedException();
|
|
||||||
|
|
||||||
public int this[int index]
|
public int this[int index]
|
||||||
{
|
{
|
||||||
@ -473,7 +472,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
/// <summary>as Union sets</summary>
|
/// <summary>as Union sets</summary>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void UnionWith(EcsReadonlyGroup group) => UnionWith(group.GetSource_Internal());
|
public void UnionWith(EcsReadonlyGroup group) { UnionWith(group.GetSource_Internal()); }
|
||||||
/// <summary>as Union sets</summary>
|
/// <summary>as Union sets</summary>
|
||||||
public void UnionWith(EcsSpan span)
|
public void UnionWith(EcsSpan span)
|
||||||
{
|
{
|
||||||
@ -1226,19 +1225,14 @@ namespace DCFApixels.DragonECS
|
|||||||
public int Current
|
public int Current
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get => _dense[_index];
|
get { return _dense[_index]; }
|
||||||
}
|
}
|
||||||
object IEnumerator.Current { get { return Current; } }
|
object IEnumerator.Current { get { return Current; } }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool MoveNext()
|
public bool MoveNext() { return --_index > 0; } // проверка с учтом что отсчет начинается с индекса 1
|
||||||
{
|
|
||||||
// проверка с учтом что отсчет начинается с индекса 1
|
|
||||||
return --_index > 0;
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Dispose() { }
|
void IDisposable.Dispose() { }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||||
public void Reset() { }
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -62,9 +62,9 @@ namespace DCFApixels.DragonECS
|
|||||||
private sealed class DummyHandler : IEcsComponentLifecycle<T>
|
private sealed class DummyHandler : IEcsComponentLifecycle<T>
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Enable(ref T component) => component = default;
|
public void Enable(ref T component) { component = default; }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Disable(ref T component) => component = default;
|
public void Disable(ref T component) { component = default; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -95,7 +95,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private sealed class DummyHandler : IEcsComponentCopy<T>
|
private sealed class DummyHandler : IEcsComponentCopy<T>
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Copy(ref T from, ref T to) => to = from;
|
public void Copy(ref T from, ref T to) { to = from; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -460,7 +460,7 @@ namespace DCFApixels.DragonECS
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public override int GetHashCode() => hash;
|
public override int GetHashCode() { return hash; }
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -429,7 +429,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Reset() { _index = -1; }
|
public void Reset() { _index = -1; }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Dispose() { }
|
void IDisposable.Dispose() { }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ namespace DCFApixels.DragonECS
|
|||||||
where T : IEcsPoolImplementation, new()
|
where T : IEcsPoolImplementation, new()
|
||||||
{
|
{
|
||||||
public readonly T instance;
|
public readonly T instance;
|
||||||
public PoolCache(T instance) => this.instance = instance;
|
public PoolCache(T instance) { this.instance = instance; }
|
||||||
void IEcsWorldComponent<PoolCache<T>>.Init(ref PoolCache<T> component, EcsWorld world)
|
void IEcsWorldComponent<PoolCache<T>>.Init(ref PoolCache<T> component, EcsWorld world)
|
||||||
{
|
{
|
||||||
component = new PoolCache<T>(world.CreatePool<T>());
|
component = new PoolCache<T>(world.CreatePool<T>());
|
||||||
@ -22,7 +22,7 @@ namespace DCFApixels.DragonECS
|
|||||||
where T : EcsAspect, new()
|
where T : EcsAspect, new()
|
||||||
{
|
{
|
||||||
public readonly T instance;
|
public readonly T instance;
|
||||||
public AspectCache(T instance) => this.instance = instance;
|
public AspectCache(T instance) { this.instance = instance; }
|
||||||
void IEcsWorldComponent<AspectCache<T>>.Init(ref AspectCache<T> component, EcsWorld world)
|
void IEcsWorldComponent<AspectCache<T>>.Init(ref AspectCache<T> component, EcsWorld world)
|
||||||
{
|
{
|
||||||
component = new AspectCache<T>(EcsAspect.Builder.New<T>(world));
|
component = new AspectCache<T>(EcsAspect.Builder.New<T>(world));
|
||||||
@ -36,7 +36,7 @@ namespace DCFApixels.DragonECS
|
|||||||
where T : EcsQueryExecutor, new()
|
where T : EcsQueryExecutor, new()
|
||||||
{
|
{
|
||||||
public readonly T instance;
|
public readonly T instance;
|
||||||
public ExeccutorCache(T instance) => this.instance = instance;
|
public ExeccutorCache(T instance) { this.instance = instance; }
|
||||||
void IEcsWorldComponent<ExeccutorCache<T>>.Init(ref ExeccutorCache<T> component, EcsWorld world)
|
void IEcsWorldComponent<ExeccutorCache<T>>.Init(ref ExeccutorCache<T> component, EcsWorld world)
|
||||||
{
|
{
|
||||||
T instance = new T();
|
T instance = new T();
|
||||||
|
|||||||
@ -10,9 +10,9 @@ namespace DCFApixels.DragonECS
|
|||||||
public struct EcsWorldCmp<T> where T : struct
|
public struct EcsWorldCmp<T> where T : struct
|
||||||
{
|
{
|
||||||
private short _worldID;
|
private short _worldID;
|
||||||
public EcsWorldCmp(short worldID) => _worldID = worldID;
|
public EcsWorldCmp(short worldID) { _worldID = worldID; }
|
||||||
public EcsWorld World => EcsWorld.GetWorld(_worldID);
|
public EcsWorld World { get { return EcsWorld.GetWorld(_worldID); } }
|
||||||
public ref T Value => ref EcsWorld.GetData<T>(_worldID);
|
public ref T Value { get { return ref EcsWorld.GetData<T>(_worldID); } }
|
||||||
}
|
}
|
||||||
public partial class EcsWorld
|
public partial class EcsWorld
|
||||||
{
|
{
|
||||||
|
|||||||
@ -11,52 +11,6 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
{
|
{
|
||||||
int Next { get; }
|
int Next { get; }
|
||||||
}
|
}
|
||||||
internal readonly struct LinkedIndexesIterator<T> : IEnumerable<int>
|
|
||||||
where T : ILinkedNext
|
|
||||||
{
|
|
||||||
private readonly T[] _array;
|
|
||||||
private readonly int _count;
|
|
||||||
private readonly int _startIndex;
|
|
||||||
public LinkedIndexesIterator(T[] array, int count, int startIndex)
|
|
||||||
{
|
|
||||||
_array = array;
|
|
||||||
_count = count;
|
|
||||||
_startIndex = startIndex;
|
|
||||||
}
|
|
||||||
public Enumerator GetEnumerator()
|
|
||||||
{
|
|
||||||
return new Enumerator(_array, _count, _startIndex);
|
|
||||||
}
|
|
||||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
|
||||||
public struct Enumerator : IEnumerator<int>
|
|
||||||
{
|
|
||||||
private readonly T[] _array;
|
|
||||||
private readonly int _count;
|
|
||||||
private int _index;
|
|
||||||
private int _counter;
|
|
||||||
public Enumerator(T[] array, int count, int index)
|
|
||||||
{
|
|
||||||
_array = array;
|
|
||||||
_count = count;
|
|
||||||
_index = index;
|
|
||||||
_counter = 0;
|
|
||||||
}
|
|
||||||
public int Current { get { return _index; } }
|
|
||||||
object IEnumerator.Current { get { return Current; } }
|
|
||||||
public bool MoveNext()
|
|
||||||
{
|
|
||||||
if (++_counter > _count) { return false; }
|
|
||||||
if (_counter > 1)
|
|
||||||
{
|
|
||||||
_index = _array[_index].Next;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public void Dispose() { }
|
|
||||||
public void Reset() { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
internal readonly struct LinkedListIterator<T> : IEnumerable<T>
|
internal readonly struct LinkedListIterator<T> : IEnumerable<T>
|
||||||
where T : ILinkedNext
|
where T : ILinkedNext
|
||||||
{
|
{
|
||||||
@ -88,7 +42,11 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
_index = index;
|
_index = index;
|
||||||
_counter = 0;
|
_counter = 0;
|
||||||
}
|
}
|
||||||
public ref readonly T Current { get { return ref _array[_index]; } }
|
public ref T Current
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
get { return ref _array[_index]; }
|
||||||
|
}
|
||||||
T IEnumerator<T>.Current { get { return _array[_index]; } }
|
T IEnumerator<T>.Current { get { return _array[_index]; } }
|
||||||
object IEnumerator.Current { get { return Current; } }
|
object IEnumerator.Current { get { return Current; } }
|
||||||
public bool MoveNext()
|
public bool MoveNext()
|
||||||
@ -100,10 +58,12 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public void Dispose() { }
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Reset() { throw new NotSupportedException(); }
|
void IDisposable.Dispose() { }
|
||||||
|
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static class ArrayUtility
|
internal static class ArrayUtility
|
||||||
{
|
{
|
||||||
private static int GetHighBitNumber(uint bits)
|
private static int GetHighBitNumber(uint bits)
|
||||||
@ -183,12 +143,12 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
this.start = start;
|
this.start = start;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
}
|
}
|
||||||
public static EnumerableInt Range(int start, int length) => new EnumerableInt(start, length);
|
public static EnumerableInt Range(int start, int length) { return new EnumerableInt(start, length); }
|
||||||
public static EnumerableInt StartEnd(int start, int end) => new EnumerableInt(start, end - start);
|
public static EnumerableInt StartEnd(int start, int end) { return new EnumerableInt(start, end - start); }
|
||||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() => GetEnumerator();
|
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public Enumerator GetEnumerator() => new Enumerator(start, start + length);
|
public Enumerator GetEnumerator() { return new Enumerator(start, start + length); }
|
||||||
public struct Enumerator : IEnumerator<int>
|
public struct Enumerator : IEnumerator<int>
|
||||||
{
|
{
|
||||||
private readonly int _max;
|
private readonly int _max;
|
||||||
@ -202,16 +162,16 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
public int Current
|
public int Current
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get => _current;
|
get { return _current; }
|
||||||
}
|
}
|
||||||
object IEnumerator.Current => Current;
|
object IEnumerator.Current { get { return Current; } }
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool MoveNext() => ++_current < _max;
|
public bool MoveNext() { return ++_current < _max; }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Reset() { }
|
void IDisposable.Dispose() { }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||||
public void Dispose() { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal static unsafe class UnmanagedArrayUtility
|
internal static unsafe class UnmanagedArrayUtility
|
||||||
|
|||||||
@ -512,9 +512,9 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
byte result = ToByte(bitsString);
|
byte result = ToByte(bitsString);
|
||||||
return *(bool*)&result;
|
return *(bool*)&result;
|
||||||
}
|
}
|
||||||
public static short ToShort(string bitsString) => (short)ToUShort(bitsString);
|
public static short ToShort(string bitsString) { return (short)ToUShort(bitsString); }
|
||||||
public static int ToInt(string bitsString) => (int)ToUInt(bitsString);
|
public static int ToInt(string bitsString) { return (int)ToUInt(bitsString); }
|
||||||
public static long ToLong(string bitsString) => (long)ToULong(bitsString);
|
public static long ToLong(string bitsString) { return (long)ToULong(bitsString); }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region XorShift
|
#region XorShift
|
||||||
@ -625,249 +625,18 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
#region FindBitsResult removed
|
|
||||||
/*
|
|
||||||
public unsafe struct FindBitsResult8 : IEnumerable<byte>
|
|
||||||
{
|
|
||||||
private fixed byte _numbers[8];
|
|
||||||
public readonly byte Count;
|
|
||||||
public int this[int index]
|
|
||||||
{
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
get => _numbers[index];
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public FindBitsResult8(uint bits)
|
|
||||||
{
|
|
||||||
unchecked
|
|
||||||
{
|
|
||||||
Count = (byte)CountBits(bits);
|
|
||||||
for (int i = 0; i < Count; i++)
|
|
||||||
{
|
|
||||||
int number = GetHighBitNumber(bits);
|
|
||||||
_numbers[i] = (byte)number;
|
|
||||||
bits ^= 1u << number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
private static ReadOnlySpan<byte> CreateSpanInternal(FindBitsResult8 a)
|
|
||||||
{
|
|
||||||
return new ReadOnlySpan<byte>(a._numbers, a.Count);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public ReadOnlySpan<byte> ToSpan()
|
|
||||||
{
|
|
||||||
return CreateSpanInternal(this);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
private static FindBitsResultEnumerator GetEnumeratorInternal(FindBitsResult8 a)
|
|
||||||
{
|
|
||||||
return new FindBitsResultEnumerator(a._numbers, a.Count);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public FindBitsResultEnumerator GetEnumerator()
|
|
||||||
{
|
|
||||||
return GetEnumeratorInternal(this);
|
|
||||||
}
|
|
||||||
IEnumerator<byte> IEnumerable<byte>.GetEnumerator() => GetEnumerator();
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe struct FindBitsResult16 : IEnumerable<byte>
|
|
||||||
{
|
|
||||||
private fixed byte _numbers[16];
|
|
||||||
public readonly byte Count;
|
|
||||||
public int this[int index]
|
|
||||||
{
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
get => _numbers[index];
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public FindBitsResult16(uint bits)
|
|
||||||
{
|
|
||||||
unchecked
|
|
||||||
{
|
|
||||||
Count = (byte)CountBits(bits);
|
|
||||||
for (int i = 0; i < Count; i++)
|
|
||||||
{
|
|
||||||
int number = GetHighBitNumber(bits);
|
|
||||||
_numbers[i] = (byte)number;
|
|
||||||
bits ^= 1u << number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
private static ReadOnlySpan<byte> CreateSpanInternal(FindBitsResult16 a)
|
|
||||||
{
|
|
||||||
return new ReadOnlySpan<byte>(a._numbers, a.Count);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public ReadOnlySpan<byte> ToSpan()
|
|
||||||
{
|
|
||||||
return CreateSpanInternal(this);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
private static FindBitsResultEnumerator GetEnumeratorInternal(FindBitsResult16 a)
|
|
||||||
{
|
|
||||||
return new FindBitsResultEnumerator(a._numbers, a.Count);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public FindBitsResultEnumerator GetEnumerator()
|
|
||||||
{
|
|
||||||
return GetEnumeratorInternal(this);
|
|
||||||
}
|
|
||||||
IEnumerator<byte> IEnumerable<byte>.GetEnumerator() => GetEnumerator();
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe struct FindBitsResult32 : IEnumerable<byte>
|
|
||||||
{
|
|
||||||
public fixed byte _numbers[32];
|
|
||||||
public readonly byte Count;
|
|
||||||
public int this[int index]
|
|
||||||
{
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
get => _numbers[index];
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public FindBitsResult32(uint bits)
|
|
||||||
{
|
|
||||||
unchecked
|
|
||||||
{
|
|
||||||
Count = (byte)CountBits(bits);
|
|
||||||
for (int i = 0; i < Count; i++)
|
|
||||||
{
|
|
||||||
int number = GetHighBitNumber(bits);
|
|
||||||
_numbers[i] = (byte)number;
|
|
||||||
bits ^= 1u << number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
private static ReadOnlySpan<byte> CreateSpanInternal(FindBitsResult32 a)
|
|
||||||
{
|
|
||||||
return new ReadOnlySpan<byte>(a._numbers, a.Count);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public ReadOnlySpan<byte> ToSpan()
|
|
||||||
{
|
|
||||||
return CreateSpanInternal(this);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
private static FindBitsResultEnumerator GetEnumeratorInternal(FindBitsResult32 a)
|
|
||||||
{
|
|
||||||
return new FindBitsResultEnumerator(a._numbers, a.Count);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public FindBitsResultEnumerator GetEnumerator()
|
|
||||||
{
|
|
||||||
return GetEnumeratorInternal(this);
|
|
||||||
}
|
|
||||||
IEnumerator<byte> IEnumerable<byte>.GetEnumerator() => GetEnumerator();
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe struct FindBitsResult64 : IEnumerable<byte>
|
|
||||||
{
|
|
||||||
private fixed byte _numbers[64];
|
|
||||||
public readonly byte Count;
|
|
||||||
public int this[int index]
|
|
||||||
{
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
get => _numbers[index];
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public FindBitsResult64(ulong bits)
|
|
||||||
{
|
|
||||||
unchecked
|
|
||||||
{
|
|
||||||
Count = (byte)CountBits(bits);
|
|
||||||
for (int i = 0; i < Count; i++)
|
|
||||||
{
|
|
||||||
int number = GetHighBitNumber(bits);
|
|
||||||
_numbers[i] = (byte)number;
|
|
||||||
bits ^= 1u << number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
private static ReadOnlySpan<byte> CreateSpanInternal(FindBitsResult64 a)
|
|
||||||
{
|
|
||||||
return new ReadOnlySpan<byte>(a._numbers, a.Count);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public ReadOnlySpan<byte> ToSpan()
|
|
||||||
{
|
|
||||||
return CreateSpanInternal(this);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
private static FindBitsResultEnumerator GetEnumeratorInternal(FindBitsResult64 a)
|
|
||||||
{
|
|
||||||
return new FindBitsResultEnumerator(a._numbers, a.Count);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public FindBitsResultEnumerator GetEnumerator()
|
|
||||||
{
|
|
||||||
return GetEnumeratorInternal(this);
|
|
||||||
}
|
|
||||||
IEnumerator<byte> IEnumerable<byte>.GetEnumerator() => GetEnumerator();
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe struct FindBitsResultEnumerator : IEnumerator<byte>
|
|
||||||
{
|
|
||||||
private byte* _numbers;
|
|
||||||
private byte _count;
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public FindBitsResultEnumerator(byte* numbers, byte count)
|
|
||||||
{
|
|
||||||
_numbers = numbers;
|
|
||||||
_count = count;
|
|
||||||
}
|
|
||||||
public byte Current
|
|
||||||
{
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return *_numbers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
object IEnumerator.Current => Current;
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public bool MoveNext()
|
|
||||||
{
|
|
||||||
return _count-- > 0;
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public void Dispose() { }
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public void Reset() { }
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region FindBitsIterator
|
#region FindBitsIterator
|
||||||
public struct FindBitsIterator8 : IEnumerable<int>
|
public struct FindBitsIterator8 : IEnumerable<int>
|
||||||
{
|
{
|
||||||
private Enumerator _enumerator;
|
private Enumerator _enumerator;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public FindBitsIterator8(sbyte bits)
|
public FindBitsIterator8(sbyte bits) { _enumerator = new Enumerator((byte)bits); }
|
||||||
{
|
|
||||||
_enumerator = new Enumerator((byte)bits);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public FindBitsIterator8(byte bits)
|
public FindBitsIterator8(byte bits) { _enumerator = new Enumerator(bits); }
|
||||||
{
|
|
||||||
_enumerator = new Enumerator(bits);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public Enumerator GetEnumerator()
|
public Enumerator GetEnumerator() { return _enumerator; }
|
||||||
{
|
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
|
||||||
return _enumerator;
|
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||||
}
|
|
||||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() => GetEnumerator();
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
||||||
public struct Enumerator : IEnumerator<int>
|
public struct Enumerator : IEnumerator<int>
|
||||||
{
|
{
|
||||||
private uint _bits;
|
private uint _bits;
|
||||||
@ -888,16 +657,12 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
object IEnumerator.Current => Current;
|
object IEnumerator.Current { get { return Current; } }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool MoveNext()
|
public bool MoveNext() { return _count-- > 0; }
|
||||||
{
|
|
||||||
return _count-- > 0;
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
void IDisposable.Dispose() { }
|
void IDisposable.Dispose() { }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||||
void IEnumerator.Reset() { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -905,22 +670,13 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
{
|
{
|
||||||
private Enumerator _enumerator;
|
private Enumerator _enumerator;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public FindBitsIterator16(short bits)
|
public FindBitsIterator16(short bits) { _enumerator = new Enumerator((ushort)bits); }
|
||||||
{
|
|
||||||
_enumerator = new Enumerator((ushort)bits);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public FindBitsIterator16(ushort bits)
|
public FindBitsIterator16(ushort bits) { _enumerator = new Enumerator(bits); }
|
||||||
{
|
|
||||||
_enumerator = new Enumerator(bits);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public Enumerator GetEnumerator()
|
public Enumerator GetEnumerator() { return _enumerator; }
|
||||||
{
|
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
|
||||||
return _enumerator;
|
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||||
}
|
|
||||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() => GetEnumerator();
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
||||||
public struct Enumerator : IEnumerator<int>
|
public struct Enumerator : IEnumerator<int>
|
||||||
{
|
{
|
||||||
private uint _bits;
|
private uint _bits;
|
||||||
@ -941,16 +697,12 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
object IEnumerator.Current => Current;
|
object IEnumerator.Current { get { return Current; } }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool MoveNext()
|
public bool MoveNext() { return _count-- > 0; }
|
||||||
{
|
|
||||||
return _count-- > 0;
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
void IDisposable.Dispose() { }
|
void IDisposable.Dispose() { }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||||
void IEnumerator.Reset() { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -958,22 +710,13 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
{
|
{
|
||||||
private Enumerator _enumerator;
|
private Enumerator _enumerator;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public FindBitsIterator32(int bits)
|
public FindBitsIterator32(int bits) { _enumerator = new Enumerator((uint)bits); }
|
||||||
{
|
|
||||||
_enumerator = new Enumerator((uint)bits);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public FindBitsIterator32(uint bits)
|
public FindBitsIterator32(uint bits) { _enumerator = new Enumerator(bits); }
|
||||||
{
|
|
||||||
_enumerator = new Enumerator(bits);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public Enumerator GetEnumerator()
|
public Enumerator GetEnumerator() { return _enumerator; }
|
||||||
{
|
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
|
||||||
return _enumerator;
|
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||||
}
|
|
||||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() => GetEnumerator();
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
||||||
public struct Enumerator : IEnumerator<int>
|
public struct Enumerator : IEnumerator<int>
|
||||||
{
|
{
|
||||||
private uint _bits;
|
private uint _bits;
|
||||||
@ -994,16 +737,12 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
object IEnumerator.Current => Current;
|
object IEnumerator.Current { get { return Current; } }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool MoveNext()
|
public bool MoveNext() { return _count-- > 0; }
|
||||||
{
|
|
||||||
return _count-- > 0;
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
void IDisposable.Dispose() { }
|
void IDisposable.Dispose() { }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||||
void IEnumerator.Reset() { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1011,22 +750,13 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
{
|
{
|
||||||
private Enumerator _enumerator;
|
private Enumerator _enumerator;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public FindBitsIterator64(long bits)
|
public FindBitsIterator64(long bits) { _enumerator = new Enumerator((ulong)bits); }
|
||||||
{
|
|
||||||
_enumerator = new Enumerator((ulong)bits);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public FindBitsIterator64(ulong bits)
|
public FindBitsIterator64(ulong bits) { _enumerator = new Enumerator(bits); }
|
||||||
{
|
|
||||||
_enumerator = new Enumerator(bits);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public Enumerator GetEnumerator()
|
public Enumerator GetEnumerator() { return _enumerator; }
|
||||||
{
|
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
|
||||||
return _enumerator;
|
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||||
}
|
|
||||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() => GetEnumerator();
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
||||||
public struct Enumerator : IEnumerator<int>
|
public struct Enumerator : IEnumerator<int>
|
||||||
{
|
{
|
||||||
private ulong _bits;
|
private ulong _bits;
|
||||||
@ -1047,16 +777,12 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
object IEnumerator.Current => Current;
|
object IEnumerator.Current { get { return Current; } }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool MoveNext()
|
public bool MoveNext() { return _count-- > 0; }
|
||||||
{
|
|
||||||
return _count-- > 0;
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
void IDisposable.Dispose() { }
|
void IDisposable.Dispose() { }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||||
void IEnumerator.Reset() { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -261,10 +261,8 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Enumerable
|
#region Enumerable
|
||||||
public Enumerator GetEnumerator()
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
{
|
public Enumerator GetEnumerator() { return new Enumerator(_dense, 0, _usedCount); }
|
||||||
return new Enumerator(_dense, 0, _usedCount);
|
|
||||||
}
|
|
||||||
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
|
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
|
||||||
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||||
public struct Enumerator : IEnumerator<int>
|
public struct Enumerator : IEnumerator<int>
|
||||||
@ -272,17 +270,25 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
private readonly int[] _dense;
|
private readonly int[] _dense;
|
||||||
private readonly int _count;
|
private readonly int _count;
|
||||||
private int _index;
|
private int _index;
|
||||||
public int Current => _dense[_index];
|
public int Current
|
||||||
object IEnumerator.Current => Current;
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
get { return _dense[_index]; }
|
||||||
|
}
|
||||||
|
object IEnumerator.Current { get { return Current; } }
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public Enumerator(int[] dense, int startIndex, int count)
|
public Enumerator(int[] dense, int startIndex, int count)
|
||||||
{
|
{
|
||||||
_dense = dense;
|
_dense = dense;
|
||||||
_count = startIndex + count;
|
_count = startIndex + count;
|
||||||
_index = startIndex - 1;
|
_index = startIndex - 1;
|
||||||
}
|
}
|
||||||
public bool MoveNext() => ++_index < _count;
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Dispose() { }
|
public bool MoveNext() { return ++_index < _count; }
|
||||||
public void Reset() => _index = -1;
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
void IDisposable.Dispose() { }
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public void Reset() { _index = -1; }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -303,19 +309,15 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
private static class ThrowHalper
|
private static class ThrowHalper
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
public static void ThrowIsAlreadyInUse(int id) => throw new ArgumentException($"Id {id} is already in use.");
|
public static void ThrowIsAlreadyInUse(int id) { throw new ArgumentException($"Id {id} is already in use."); }
|
||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
public static void ThrowIsHasBeenReserved(int id) => throw new ArgumentException($"Id {id} has been reserved.");
|
public static void ThrowIsHasBeenReserved(int id) { throw new ArgumentException($"Id {id} has been reserved."); }
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
public static void ThrowIsNotUsed(int id) => throw new ArgumentException($"Id {id} is not used.");
|
public static void ThrowIsNotUsed(int id) { throw new ArgumentException($"Id {id} is not used."); }
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
public static void ThrowIsNotAvailable(int id) => throw new ArgumentException($"Id {id} is not available.");
|
public static void ThrowIsNotAvailable(int id) { throw new ArgumentException($"Id {id} is not available."); }
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
public static void ThrowIsNullID(int id) => throw new ArgumentException($"Id {id} cannot be released because it is used as a null id.");
|
public static void ThrowIsNullID(int id) { throw new ArgumentException($"Id {id} cannot be released because it is used as a null id."); }
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
public static void UndefinedException() { throw new Exception(); }
|
public static void UndefinedException() { throw new Exception(); }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,15 +32,15 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
#region Properties
|
#region Properties
|
||||||
public TValue this[int keyX, int keyY]
|
public TValue this[int keyX, int keyY]
|
||||||
{
|
{
|
||||||
get => _entries[FindEntry((keyX << 16) | keyY)].value;
|
get { return _entries[FindEntry((keyX << 16) | keyY)].value; }
|
||||||
set => Insert(keyX + (keyY << 16), value);
|
set { Insert(keyX + (keyY << 16), value); }
|
||||||
}
|
}
|
||||||
public TValue this[int key]
|
public TValue this[int key]
|
||||||
{
|
{
|
||||||
get => _entries[FindEntry(key)].value;
|
get { return _entries[FindEntry(key)].value; }
|
||||||
set => Insert(key, value);
|
set { Insert(key, value); }
|
||||||
}
|
}
|
||||||
public int Count => _count;
|
public int Count { get { return _count; } }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
@ -57,22 +57,21 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
|
|
||||||
#region Add/Contains/Remove
|
#region Add/Contains/Remove
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Add(int keyX, int keyY, TValue value) => Add((keyX << 16) | keyY, value);
|
public void Add(int keyX, int keyY, TValue value) { Add((keyX << 16) | keyY, value); }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Add(int key, TValue value)
|
public void Add(int key, TValue value)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (Contains(key))
|
if (Contains(key)) { throw new ArgumentException("Contains(hashKey) is true"); }
|
||||||
throw new ArgumentException("Contains(hashKey) is true");
|
|
||||||
#endif
|
#endif
|
||||||
Insert(key, value);
|
Insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Contains(int keyX, int keyY) => FindEntry((keyX << 16) | keyY) >= 0;
|
public bool Contains(int keyX, int keyY) { return FindEntry((keyX << 16) | keyY) >= 0; }
|
||||||
public bool Contains(int key) => FindEntry(key) >= 0;
|
public bool Contains(int key) { return FindEntry(key) >= 0; }
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool Remove(int keyX, int keyY) => Remove((keyX << 16) | keyY);
|
public bool Remove(int keyX, int keyY) { return Remove((keyX << 16) | keyY); }
|
||||||
public bool Remove(int key)
|
public bool Remove(int key)
|
||||||
{
|
{
|
||||||
int bucket = key & _modBitMask;
|
int bucket = key & _modBitMask;
|
||||||
|
|||||||
@ -55,10 +55,10 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
return CollectionUtility.AutoToString(EnumerableInt.Range(0, Length).Select(i => ptr[i]), "ua");
|
return CollectionUtility.AutoToString(EnumerableInt.Range(0, Length).Select(i => ptr[i]), "ua");
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() => GetEnumerator();
|
IEnumerator<T> IEnumerable<T>.GetEnumerator() { return GetEnumerator(); }
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public Enumerator GetEnumerator() => new Enumerator(ptr, Length);
|
public Enumerator GetEnumerator() { return new Enumerator(ptr, Length); }
|
||||||
public struct Enumerator : IEnumerator<T>
|
public struct Enumerator : IEnumerator<T>
|
||||||
{
|
{
|
||||||
private readonly T* _ptr;
|
private readonly T* _ptr;
|
||||||
@ -74,15 +74,14 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
public T Current
|
public T Current
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get => _ptr[_index];
|
get { return _ptr[_index]; }
|
||||||
}
|
}
|
||||||
object IEnumerator.Current => Current;
|
object IEnumerator.Current { get { return Current; } }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool MoveNext() => ++_index < _length;
|
public bool MoveNext() { return ++_index < _length; }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Reset() { }
|
void IDisposable.Dispose() { }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
void IEnumerator.Reset() { throw new NotSupportedException(); }
|
||||||
public void Dispose() { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class DebuggerProxy
|
internal class DebuggerProxy
|
||||||
|
|||||||
@ -270,8 +270,8 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IEnumerator - IntelliSense hack
|
#region IEnumerator - IntelliSense hack
|
||||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() => throw new NotImplementedException();
|
IEnumerator<T> IEnumerable<T>.GetEnumerator() { throw new NotImplementedException(); }
|
||||||
IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException();
|
IEnumerator IEnumerable.GetEnumerator() { throw new NotImplementedException(); }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region MarkersConverter
|
#region MarkersConverter
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user