Mirror of Svelto.ECS because we're a fan of it
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.6KB

  1. using System.Runtime.CompilerServices;
  2. namespace Svelto.ECS.DataStructures
  3. {
  4. public struct NativeDynamicArrayCast<T> where T : struct
  5. {
  6. public NativeDynamicArrayCast(NativeDynamicArray array) : this() { _array = array; }
  7. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  8. public int Count() => _array.Count<T>();
  9. public int count => _array.Count<T>();
  10. public ref T this[int index]
  11. {
  12. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  13. get => ref _array.Get<T>((uint) index);
  14. }
  15. public ref T this[uint index]
  16. {
  17. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  18. get => ref _array.Get<T>(index);
  19. }
  20. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  21. public void Add(in T id) { _array.Add(id); }
  22. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  23. public void UnorderedRemoveAt(uint index) { _array.UnorderedRemoveAt<T>(index); }
  24. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  25. public void RemoveAt(uint index) { _array.RemoveAt<T>(index); }
  26. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  27. public void Clear() { _array.FastClear(); }
  28. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  29. public void Dispose() { _array.Dispose(); }
  30. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  31. public ref T AddAt(uint lastIndex) { return ref _array.AddAt<T>(lastIndex); }
  32. public bool isValid => _array.isValid;
  33. NativeDynamicArray _array;
  34. }
  35. }