public static unsafe void CopyTo <T>(this Span <T> source, UnmanagedSpan <T> dest) where T : unmanaged { fixed(T *sourcePtr = source) fixed(T * destPtr = &dest.GetPinnableReference()) { Unsafe.CopyBlockUnaligned(destPtr, sourcePtr, (uint)source.Length); } }
/// <summary>Copies the items in the array to a given destination.</summary> /// <param name="destination">The destination span where the items should be copied.</param> /// <exception cref="ArgumentOutOfRangeException"><see cref="Length" /> is greater than <paramref name="destination" />.</exception> public void CopyTo(UnmanagedSpan <T> destination) { var items = _items; var length = _length; ThrowIfNotInInsertBounds(length, destination.Length); CopyArrayUnsafe(destination.GetPointerUnsafe(0), items, length); }
/// <summary>Copies the items of the stack to a span.</summary> /// <param name="destination">The span to which the items will be copied.</param> /// <exception cref="ArgumentOutOfRangeException"><see cref="Count" /> is greater than the length of <paramref name="destination" />.</exception> public readonly void CopyTo(UnmanagedSpan <T> destination) { var count = Count; if (count != 0) { ThrowIfNotInInsertBounds(count, destination.Length); CopyArrayUnsafe(destination.GetPointerUnsafe(0), _items.GetPointerUnsafe(0), count); } }
/// <summary>Copies the items in the array to a given destination.</summary> /// <param name="destination">The destination span where the items should be copied.</param> /// <exception cref="ArgumentOutOfRangeException"><see cref="Length" /> is greater than <paramref name="destination" />.</exception> public void CopyTo(UnmanagedSpan <T> destination) { AssertNotNull(this); var items = &_data->Item; var length = _data->Length; ThrowIfNotInInsertBounds(length, destination.Length); CopyArrayUnsafe(destination.GetPointerUnsafe(0), items, length); }
public UnmanagedSpan <byte> FinalizeAsBytes() { UnmanagedSpan <byte> span = Memory.MemoryManager.GetReadWriteExeBlock( PostWrap.Length + PrefWrap.Length + _bodyMemory.Length); Unsafe.CopyBlockUnaligned(ref span[_wraps ? PrefWrap.Length : 0], ref _bodyMemory[0], (uint)_bodyMemory.Length); if (_wraps) { Unsafe.CopyBlockUnaligned(ref span[0], ref PrefWrap[0], 4U); Unsafe.CopyBlockUnaligned(ref span[PrefWrap.Length + _bodyMemory.Length], ref PostWrap[0], 5U); } return(span); }
/// <summary>Copies the items of the queue to a span.</summary> /// <param name="destination">The span to which the items will be copied.</param> /// <exception cref="ArgumentOutOfRangeException"><see cref="Count" /> is greater than the length of <paramref name="destination" />.</exception> public readonly void CopyTo(UnmanagedSpan <T> destination) { var count = Count; if (count != 0) { ThrowIfNotInInsertBounds(count, destination.Length); var head = _head; var tail = _tail; if ((head < tail) || (tail == 0)) { CopyArrayUnsafe(destination.GetPointerUnsafe(0), _items.GetPointerUnsafe(head), count); } else { var headLength = count - head; CopyArrayUnsafe(destination.GetPointerUnsafe(0), _items.GetPointerUnsafe(head), headLength); CopyArrayUnsafe(destination.GetPointerUnsafe(headLength), _items.GetPointerUnsafe(0), tail); } } }
internal Enumerator(UnmanagedSpan <T> span) { _span = span; _index = nuint.MaxValue; }
public DebugView(UnmanagedSpan <T> span) { _span = span; }
/// <inheritdoc cref="UnmanagedSpan{T}.CopyTo(UnmanagedSpan{T})" /> public void CopyTo(UnmanagedSpan <T> destination) => _span.CopyTo(destination);
/// <summary>Initializes a new instance of the <see cref="UnmanagedReadOnlySpan{T}" /> struct.</summary> /// <param name="span">The underlying span for the readonly span.</param> public UnmanagedReadOnlySpan(UnmanagedSpan <T> span) { _span = span; }