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]); } }
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); }
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); }
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); }
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; } }
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));
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]); } }
public static unsafe void Prepend <TElement>(this IPrependSpan <TElement> collection, TElement *elements, Int32 length) where TElement : unmanaged => collection.Prepend(new Span <TElement>(elements, length));
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]); } }