using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RageCoop.Core { /// /// A light-weight and less restricted implementation of , gonna be used at some point, maybe? /// /// public readonly unsafe struct XSpan where T : unmanaged { public XSpan(void* address, int len) { Address = (T*)address; Length = len; } public T this[int i] { get { return Address[i]; } set { Address[i] = value; } } public readonly T* Address; public readonly int Length; public void CopyTo(XSpan dest, int destStart = 0) { for (int i = 0; i < Length; i++) { dest[destStart + i] = this[i]; } } public XSpan Slice(int start) => new(Address + start, Length - start); public XSpan Slice(int start, int len) => new(Address + start, len); public static implicit operator Span(XSpan s) { return new Span(s.Address, s.Length); } public static implicit operator XSpan(Span s) { fixed (T* ptr = s) { return new XSpan(ptr, s.Length); } } } }