From bb687af912461b490ff132c858c7b4e1b765bf54 Mon Sep 17 00:00:00 2001 From: Funny-ppt <1763341376@qq.com> Date: Fri, 22 Mar 2024 16:27:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=B0=8F=E7=9A=84=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=9B=E5=87=86=E5=A4=87=E5=85=A8=E9=9D=A2=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E5=88=B0=E6=95=B0=E6=8D=AE=E5=90=8E=E7=AB=AF=E5=88=B0?= =?UTF-8?q?int=E3=80=81=E9=99=8D=E4=BD=8E=E7=B2=BE=E5=BA=A6=E5=88=B0?= =?UTF-8?q?=E7=A7=92=E7=BA=A7=E5=B9=B6=E4=BC=98=E5=8C=96=E6=95=B4=E4=B8=AA?= =?UTF-8?q?=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WebHelper/Enumerate/EnumResult.cs | 13 +----------- .../WebHelper/Enumerate/EnumerateContext.cs | 20 +++++++++---------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/InfrastSim/TimeDriven/WebHelper/Enumerate/EnumResult.cs b/InfrastSim/TimeDriven/WebHelper/Enumerate/EnumResult.cs index 7771829..b52637a 100644 --- a/InfrastSim/TimeDriven/WebHelper/Enumerate/EnumResult.cs +++ b/InfrastSim/TimeDriven/WebHelper/Enumerate/EnumResult.cs @@ -1,14 +1,3 @@ namespace InfrastSim.TimeDriven.WebHelper.Enumerate; -internal struct EnumResult { - public EnumResult(OpEnumData[] comb, int init_size, in Efficiency eff, in Efficiency extra_eff) { - this.comb = comb; - this.init_size = init_size; - this.eff = eff; - this.extra_eff = extra_eff; - } - - public OpEnumData[] comb { get; set; } - public int init_size { get; set; } - public Efficiency eff { get; set; } - public Efficiency extra_eff { get; set; } +internal record struct EnumResult(OpEnumData[] comb, int init_size, Efficiency eff, Efficiency extra_eff) { } diff --git a/InfrastSim/TimeDriven/WebHelper/Enumerate/EnumerateContext.cs b/InfrastSim/TimeDriven/WebHelper/Enumerate/EnumerateContext.cs index 46b3e22..0b26d4c 100644 --- a/InfrastSim/TimeDriven/WebHelper/Enumerate/EnumerateContext.cs +++ b/InfrastSim/TimeDriven/WebHelper/Enumerate/EnumerateContext.cs @@ -1,12 +1,10 @@ using InfrastSim.Algorithms; -using InfrastSim.TimeDriven.WebHelper.Enumerate; using System.Collections; using System.Collections.Concurrent; -using System.Diagnostics; using System.Text.Json; using System.Threading.Channels; -namespace InfrastSim.TimeDriven.WebHelper; +namespace InfrastSim.TimeDriven.WebHelper.Enumerate; internal class EnumerateContext { static readonly List primes = EularSieve.Resolve((1 << 24) - 1); const int MOD = 16777213; @@ -34,7 +32,7 @@ Efficiency TestMany(Simulator simu, IEnumerable datas) { simu.FillTestOp(); } } - bool ValidateResult(Simulator simu, in EnumResult result) { + bool ValidateResult(Simulator simu, EnumResult result) { if (result.eff.IsZero()) return false; if (result.init_size == 1) return true; @@ -112,7 +110,7 @@ public IOrderedEnumerable EnumerateImpl(JsonDocument json) { .Where(v => ValidateResult(simu1, v)) .OrderByDescending(v => v.eff.GetScore()); } - static Simulator InitSimulator(in JsonElement elem) { + static Simulator InitSimulator(JsonElement elem) { var simu = new Simulator(); foreach (var prop in elem.EnumerateObject()) { simu.SetFacilityState(prop.Name, prop.Value); @@ -128,12 +126,12 @@ static int GetGroupId(OpEnumData[] comb) { return (comb.Length << 24) | (int)f; } - struct Frame { - public OpEnumData[] comb = null!; - public BitArray uset = null!; - public int gid; - public int init_size; - public Efficiency base_eff; + readonly struct Frame { + public OpEnumData[] comb { get; init; } = null!; + public BitArray uset { get; init; } = null!; + public int gid { get; init; } + public int init_size { get; init; } + public Efficiency base_eff { get; init; } public Frame(OpEnumData[] comb, Efficiency base_eff, int ucnt) { this.comb = comb;