using System.Collections; namespace Common.Distance; public readonly struct DistanceComparer : IDistanceComparer where T : IEnumerable { /// public T Reference { get; } /// public T? Hypothesis { get; } /// public double Distance { get; } public DistanceComparer(T reference) : this(reference, default) { } public DistanceComparer(T reference, T? hypothesis) { Reference = reference; Hypothesis = hypothesis; Distance = Calculator.GetDistance(Reference, Hypothesis); } /// public override string ToString() { var str = Hypothesis?.ToString(); if (Hypothesis is var hyp && Equals(hyp, Reference)) { return str ?? string.Empty; } return $"{str ?? "-"}"; } }