/// <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); }
/// <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); } } }
/// <inheritdoc cref="UnmanagedSpan{T}.GetPointerUnsafe(nuint)" /> public T *GetPointerUnsafe(nuint index) => _span.GetPointerUnsafe(index);