public void SpanHeapList() { var list = new SpanHeapList <object>(ReferenceStackAlloc.Alloc64 <object>().AsSpan()); foreach (var item in Objects) { list.Add(item); } }
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); }
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; } }
public static IEnumerable <T> AsEnumerable <T>(this SpanHeapList <T> list) => new SpanHeapListEnumerable <T>(list.Slice());