using System; using System.Collections.Generic; using System.Collections.ObjectModel; namespace MultiWheelC.TrajectoryPlanning.PathSmoothing.Output.Comparison; /// Immutable raw-path and Local G2 comparison result. public sealed class PathSmoothingComparisonResult { internal PathSmoothingComparisonResult( PathSmoothingComparisonEntry rawPathBaseline, IReadOnlyList entries, SmoothingMethod? recommendedMethod, bool isCancelled, string diagnostic) { RawPathBaseline = rawPathBaseline ?? throw new ArgumentNullException(nameof(rawPathBaseline)); Entries = CopyReadOnly(entries); RecommendedMethod = recommendedMethod; IsCancelled = isCancelled; Diagnostic = diagnostic ?? string.Empty; } public PathSmoothingComparisonEntry RawPathBaseline { get; } public IReadOnlyList Entries { get; } /// Local G2 when its published result is deterministic; otherwise null. public SmoothingMethod? RecommendedMethod { get; } public bool IsCancelled { get; } public string Diagnostic { get; } private static IReadOnlyList CopyReadOnly( IReadOnlyList source) { var copy = new List(source == null ? 0 : source.Count); if (source != null) { for (int index = 0; index < source.Count; index++) copy.Add(source[index]); } return new ReadOnlyCollection(copy); } }