Skip to content

Instantly share code, notes, and snippets.

View Artromskiy's full-sized avatar
🧭
Wanna be hired

Artromskiy

🧭
Wanna be hired
View GitHub Profile
@Artromskiy
Artromskiy / SpanExtensions
Last active August 31, 2024 12:53
C# Span Extensions. Distinct elements, Count of repetitions per element. Useful when count of elements is less than 300
using System;
using System.Collections.Generic;
namespace Utilities;
public static class SpanExtensions
{
public static int Distinct<T>(this Span<T> items)
{
EqualityComparer<T> comparer = EqualityComparer<T>.Default;