You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ListExtensions.cs 597 B

123456789101112131415161718192021222324
  1. using System;
  2. using System.Collections.Generic;
  3. namespace LLama.Extensions
  4. {
  5. internal static class ListExtensions
  6. {
  7. #if !NET6_0_OR_GREATER
  8. public static void EnsureCapacity<T>(this List<T> list, int capacity)
  9. {
  10. if (list.Capacity < capacity)
  11. list.Capacity = capacity;
  12. }
  13. #endif
  14. public static void AddSpan<T>(this List<T> list, ReadOnlySpan<T> items)
  15. {
  16. list.EnsureCapacity(list.Count + items.Length);
  17. for (var i = 0; i < items.Length; i++)
  18. list.Add(items[i]);
  19. }
  20. }
  21. }