using System; using System.Collections.Generic; using System.Collections.ObjectModel; namespace MultiWheelC.TrajectoryPlanning.PathSmoothing.Comparison; /// 一次离线比较的不可变基线、方法条目和推荐结论。 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; } /// 按公开字典序选择的方法;没有合格方法或取消时为空。 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); } }