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.

NativeDynamicArrayCast.cs 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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
  10. {
  11. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  12. get => _array.Count<T>();
  13. }
  14. public ref T this[int index]
  15. {
  16. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  17. get => ref _array.Get<T>((uint) index);
  18. }
  19. public ref T this[uint index]
  20. {
  21. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  22. get => ref _array.Get<T>(index);
  23. }
  24. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  25. public void Add(in T id) { _array.Add(id); }
  26. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  27. public void UnorderedRemoveAt(uint index) { _array.UnorderedRemoveAt<T>(index); }
  28. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  29. public void RemoveAt(uint index) { _array.RemoveAt<T>(index); }
  30. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  31. public void Clear() { _array.FastClear(); }
  32. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  33. public void Dispose() { _array.Dispose(); }
  34. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  35. public ref T AddAt(uint lastIndex) { return ref _array.AddAt<T>(lastIndex); }
  36. public bool isValid => _array.isValid;
  37. NativeDynamicArray _array;
  38. }
  39. }