Exemple #1
0
 public static unsafe void Add <TElement>(this IAdd <TElement> collection, TElement *elements, Int32 length) where TElement : unmanaged
 {
     for (Int32 i = 0; i < length; i++)
     {
         collection.Add(elements[i]);
     }
 }
Exemple #2
0
 public static unsafe Boolean Contains <TElement>(TElement *collection, Int32 count, TElement element) where TElement : unmanaged
 {
     if (collection is not null)
     {
         for (Int32 i = 0; i < count; i++)
         {
             if (Equals(collection[i], element))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #3
0
 public static unsafe Boolean Contains <TElement>(TElement *collection, Int32 count, Predicate <TElement>?predicate) where TElement : unmanaged
 {
     if (collection is not null)
     {
         for (Int32 i = 0; i < count; i++)
         {
             if (predicate?.Invoke(collection[i]) ?? false)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #4
0
 public static unsafe Boolean ContainsAny <TElement>(TElement *collection, Int32 count, ReadOnlySpan <TElement> elements) where TElement : unmanaged
 {
     Boolean[] found = new Boolean[elements.Length];
     for (Int32 c = 0; c < count; c++)
     {
         for (Int32 e = 0; e < elements.Length; e++)
         {
             if (Equals(collection[c], elements[e]))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #5
0
 public static unsafe void Insert <TElement>(this IInsert <Index, TElement> collection, Index index, TElement *elements, Int32 length) where TElement : unmanaged
 {
     for (Int32 i = 0; i < length; i++)
     {
         collection.Insert(index, elements[i]);
         index = index.Value + 1;
     }
 }
Exemple #6
0
 public static unsafe void Insert <TElement>(this IInsertSpan <Index, TElement> collection, Index index, TElement *elements, Int32 length) where TElement : unmanaged => collection.Insert(index, new Span <TElement>(elements, length));
Exemple #7
0
 public static unsafe void RemoveLast <TElement>(this IRemove <TElement> collection, TElement *elements, Int32 length) where TElement : unmanaged
 {
     for (Int32 i = 0; i < length; i++)
     {
         collection.RemoveLast(elements[i]);
     }
 }
Exemple #8
0
 public static unsafe void Prepend <TElement>(this IPrependSpan <TElement> collection, TElement *elements, Int32 length) where TElement : unmanaged => collection.Prepend(new Span <TElement>(elements, length));
Exemple #9
0
 public static unsafe void Prepend <TElement>(this IPrepend <TElement> collection, TElement *elements, Int32 length) where TElement : unmanaged
 {
     for (Int32 i = length - 1; i >= 0; i--)
     {
         collection.Prepend(elements[i]);
     }
 }