update EcsGroup

rename set operations
replace Span with ReadOnlySpan
This commit is contained in:
Mikhail 2023-06-05 00:23:18 +08:00
parent a7323363c4
commit e59ef89dfc

View File

@ -71,8 +71,8 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Bake(List<int> entities) => _source.Bake(entities); public void Bake(List<int> entities) => _source.Bake(entities);
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span<int> ToSpan() => _source.ToSpan(); public ReadOnlySpan<int> ToSpan() => _source.ToSpan();
public Span<int> ToSpan(int start, int length) => _source.ToSpan(start, length); public ReadOnlySpan<int> ToSpan(int start, int length) => _source.ToSpan(start, length);
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public int First() => _source.First(); public int First() => _source.First();
@ -163,7 +163,6 @@ namespace DCFApixels.DragonECS
{ {
return world.GetFreeGroup(); return world.GetFreeGroup();
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal EcsGroup(EcsWorld world, int denseCapacity = 64) internal EcsGroup(EcsWorld world, int denseCapacity = 64)
{ {
_source = world; _source = world;
@ -282,13 +281,13 @@ namespace DCFApixels.DragonECS
foreach (var e in this) foreach (var e in this)
entities.Add(e); entities.Add(e);
} }
public Span<int> ToSpan() => new Span<int>(_dense, 0, _count); public ReadOnlySpan<int> ToSpan() => new ReadOnlySpan<int>(_dense, 0, _count);
public Span<int> ToSpan(int start, int length) public ReadOnlySpan<int> ToSpan(int start, int length)
{ {
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
if (start + length > _count) ThrowArgumentOutOfRangeException(); if (start + length > _count) ThrowArgumentOutOfRangeException();
#endif #endif
return new Span<int>(_dense, start, length); return new ReadOnlySpan<int>(_dense, start, length);
} }
#endregion #endregion
@ -323,9 +322,9 @@ namespace DCFApixels.DragonECS
/// <summary>as Intersect sets</summary> /// <summary>as Intersect sets</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void AndWith(EcsReadonlyGroup group) => AndWith(group.GetGroupInternal()); public void IntersectWith(EcsReadonlyGroup group) => IntersectWith(group.GetGroupInternal());
/// <summary>as Intersect sets</summary> /// <summary>as Intersect sets</summary>
public void AndWith(EcsGroup group) public void IntersectWith(EcsGroup group)
{ {
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
if (World != group.World) ThrowArgumentDifferentWorldsException(); if (World != group.World) ThrowArgumentDifferentWorldsException();
@ -337,9 +336,9 @@ namespace DCFApixels.DragonECS
/// <summary>as Symmetric Except sets</summary> /// <summary>as Symmetric Except sets</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void XorWith(EcsReadonlyGroup group) => XorWith(group.GetGroupInternal()); public void SymmetricExceptWith(EcsReadonlyGroup group) => SymmetricExceptWith(group.GetGroupInternal());
/// <summary>as Symmetric Except sets</summary> /// <summary>as Symmetric Except sets</summary>
public void XorWith(EcsGroup group) public void SymmetricExceptWith(EcsGroup group)
{ {
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group.World) ThrowArgumentDifferentWorldsException(); if (_source != group.World) ThrowArgumentDifferentWorldsException();
@ -390,7 +389,7 @@ namespace DCFApixels.DragonECS
} }
/// <summary>as Intersect sets</summary> /// <summary>as Intersect sets</summary>
/// <returns>new group from pool</returns> /// <returns>new group from pool</returns>
public static EcsGroup And(EcsGroup a, EcsGroup b) public static EcsGroup Intersect(EcsGroup a, EcsGroup b)
{ {
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
if (a._source != b._source) ThrowArgumentDifferentWorldsException(); if (a._source != b._source) ThrowArgumentDifferentWorldsException();
@ -404,7 +403,7 @@ namespace DCFApixels.DragonECS
/// <summary>as Symmetric Except sets</summary> /// <summary>as Symmetric Except sets</summary>
/// <returns>new group from pool</returns> /// <returns>new group from pool</returns>
public static EcsGroup Xor(EcsGroup a, EcsGroup b) public static EcsGroup SymmetricExcept(EcsGroup a, EcsGroup b)
{ {
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
if (a._source != b._source) ThrowArgumentDifferentWorldsException(); if (a._source != b._source) ThrowArgumentDifferentWorldsException();