Ejemplo n.º 1
0
        public void SpanHeapList()
        {
            var list = new SpanHeapList <object>(ReferenceStackAlloc.Alloc64 <object>().AsSpan());

            foreach (var item in Objects)
            {
                list.Add(item);
            }
        }
Ejemplo n.º 2
0
        public int BenchSpanHeapList()
        {
            var list = new SpanHeapList<A>(ReferenceStackAlloc.Alloc64<A>().AsSpan());
            for (int i = 0; i < Array.Length; i++)
            {
                if (i % 2 == 0)
                    list.Add(Array[i]);
            }

            return list.AsEnumerable().Max(x => x.Num);
        }
Ejemplo n.º 3
0
        public SpanHeapListEnumerable(SpanHeapList <T> .SpanContainer container)
        {
            if (container.SourceSpan.Length > 0)
            {
                _sourceRef    = AsPointer(ref container.SourceSpan[0]);
                _sourceLength = container.SourceSpan.Length;
            }
            else
            {
                _sourceRef    = (void *)0;
                _sourceLength = 0;
            }

            if (container.ArraySpan.Length > 0)
            {
                _arrayRef    = AsPointer(ref container.ArraySpan[0]);
                _arrayLength = container.ArraySpan.Length;
            }
            else
            {
                _arrayRef    = (void *)0;
                _arrayLength = 0;
            }
        }
Ejemplo n.º 4
0
 public static IEnumerable <T> AsEnumerable <T>(this SpanHeapList <T> list) => new SpanHeapListEnumerable <T>(list.Slice());