/// <summary>Initializes a new instance of the <see cref="UnmanagedValueLinkedList{T}" /> struct.</summary>
    /// <param name="span">The span that is used to populate the linked list.</param>
    public UnmanagedValueLinkedList(UnmanagedReadOnlySpan <T> span)
    {
        Unsafe.SkipInit(out this);
        _count = 0;

        foreach (var value in span)
        {
            _ = AddLast(value);
        }
    }
Exemplo n.º 2
0
    /// <summary>Initializes a new instance of the <see cref="UnmanagedValueStack{T}" /> struct.</summary>
    /// <param name="span">The span that is used to populate the stack.</param>
    /// <param name="alignment">The alignment, in bytes, of the items in the stack or <c>zero</c> to use the system default.</param>
    /// <exception cref="ArgumentOutOfRangeException"><paramref name="alignment" /> is not a <c>power of two</c>.</exception>
    public UnmanagedValueStack(UnmanagedReadOnlySpan <T> span, nuint alignment = 0)
    {
        if (span.Length != 0)
        {
            var items = new UnmanagedArray <T>(span.Length, alignment);
            CopyArrayUnsafe(items.GetPointerUnsafe(0), span.GetPointerUnsafe(0), span.Length);
            _items = items;
        }
        else
        {
            if (alignment != 0)
            {
                ThrowIfNotPow2(alignment);
            }
            _items = UnmanagedArray <T> .Empty;
        }

        _count = span.Length;
    }
Exemplo n.º 3
0
        /// <summary>Initializes a new instance of the <see cref="UnmanagedValueList{T}" /> struct.</summary>
        /// <param name="span">The span that is used to populate the list.</param>
        /// <param name="alignment">The alignment, in bytes, of the items in the list or <c>zero</c> to use the system default.</param>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="alignment" /> is not a <c>power of two</c>.</exception>
        public unsafe UnmanagedValueList(UnmanagedReadOnlySpan <T> span, nuint alignment = 0)
        {
            if (span.Length != 0)
            {
                var items = new UnmanagedArray <T>(span.Length, alignment, zero: false);
                CopyArrayUnsafe <T>(items.GetPointerUnsafe(0), span.GetPointerUnsafe(0), span.Length);
                _items = items;
            }
            else
            {
                if (alignment != 0)
                {
                    ThrowIfNotPow2(alignment, nameof(alignment));
                }
                _items = UnmanagedArray <T> .Empty;
            }

            _count   = span.Length;
            _version = 0;
        }
Exemplo n.º 4
0
 public DebugView(UnmanagedReadOnlySpan <T> span)
 {
     _span = span;
 }
Exemplo n.º 5
0
 internal Enumerator(UnmanagedReadOnlySpan <T> span)
 {
     _span  = span;
     _index = nuint.MaxValue;
 }