Skip to content

Commit

Permalink
Update code.
Browse files Browse the repository at this point in the history
  • Loading branch information
KyouyamaKazusa0805 committed Sep 14, 2023
1 parent 168cd7b commit 44f3f4c
Show file tree
Hide file tree
Showing 42 changed files with 75 additions and 68 deletions.
3 changes: 1 addition & 2 deletions src/Sudoku.Analytics/Analytics/AnalyzerResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Sudoku.Analytics.Metadata;
using Sudoku.Analytics.Steps;
using Sudoku.Concepts;
using static System.Math;
using static Sudoku.Analytics.Strings.StringsAccessor;

namespace Sudoku.Analytics;
Expand Down Expand Up @@ -600,7 +599,7 @@ public string ToString(FormattingOptions options)
{
var difficulty = solvingStep.Difficulty;
currentTotal += difficulty;
currentMinimum = Min(currentMinimum, difficulty);
currentMinimum = Math.Min(currentMinimum, difficulty);
}

sb.Append(currentMinimum, 6, "0.0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Sudoku.Concepts;
using Sudoku.Rendering;
using Sudoku.Rendering.Nodes;
using static System.Math;
using static System.Numerics.BitOperations;
using static Sudoku.Analytics.CachedFields;
using static Sudoku.Analytics.ConclusionType;
Expand Down Expand Up @@ -148,7 +147,7 @@ public sealed partial class ReverseBivalueUniversalGraveStepSearcher : StepSearc
// other types will only use 1 or 2 empty cells.
for (
var incrementStep = (valuesMap.Count & 1) == 0 ? 2 : 1;
incrementStep <= Min(18 - d1Counter - d2Counter, MaxSearchingEmptyCellsCount);
incrementStep <= Math.Min(18 - d1Counter - d2Counter, MaxSearchingEmptyCellsCount);
incrementStep += 2
)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Sudoku.Concepts;
using Sudoku.Rendering;
using Sudoku.Rendering.Nodes;
using static System.Math;
using static Sudoku.Analytics.CachedFields;
using static Sudoku.Analytics.ConclusionType;
using static Sudoku.SolutionWideReadOnlyFields;
Expand Down Expand Up @@ -42,7 +41,7 @@ public sealed partial class MultiBranchWWingStepSearcher : StepSearcher
// Please note that cases whose cardinality (i.e. size of the subset) is greater than 5
// is extremely rare to appear. Therefore we can just skip on such cases,
// although the limit will miss some rare cases.
for (var size = 3; size <= Min(possibleCells.Count, 5); size++)
for (var size = 3; size <= Math.Min(possibleCells.Count, 5); size++)
{
// Iterates on each combination.
foreach (var cells in possibleCells.GetSubsets(size))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Sudoku.Concepts;
using Sudoku.Rendering;
using Sudoku.Rendering.Nodes;
using static System.Math;
using static System.Numerics.BitOperations;
using static Sudoku.Analytics.CachedFields;
using static Sudoku.Analytics.ConclusionType;
Expand Down Expand Up @@ -48,7 +47,7 @@ public sealed partial class RegularWingStepSearcher : StepSearcher
// Note that the greatest size is determined by two factors: the size that you specified
// and the number of bi-value cells in the grid.
scoped ref readonly var grid = ref context.Grid;
for (var size = 3; size <= Min(MaxSearchingPivotsCount, BivalueCells.Count); size++)
for (var size = 3; size <= Math.Min(MaxSearchingPivotsCount, BivalueCells.Count); size++)
{
// Iterate on each pivot cell.
foreach (var pivot in EmptyCells)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Sudoku.Rendering.Nodes;
using Sudoku.Text;
using Sudoku.Text.Notation;
using static System.Math;
using static Sudoku.Analytics.Strings.StringsAccessor;

namespace Sudoku.Analytics.Steps;
Expand Down Expand Up @@ -113,5 +112,5 @@ public override FormatInterpolation[] FormatInterpolationParts

/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static int IComparableStep<BlossomLoopStep>.Compare(BlossomLoopStep left, BlossomLoopStep right) => Sign(left.Difficulty - right.Difficulty);
static int IComparableStep<BlossomLoopStep>.Compare(BlossomLoopStep left, BlossomLoopStep right) => Math.Sign(left.Difficulty - right.Difficulty);
}
7 changes: 3 additions & 4 deletions src/Sudoku.Analytics/Analytics/Steps/Chaining/ChainingStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Sudoku.Concepts;
using Sudoku.Rendering;
using Sudoku.Rendering.Nodes;
using static System.Math;
using static Sudoku.Analytics.Strings.StringsAccessor;
using static Sudoku.SolutionWideReadOnlyFields;

Expand Down Expand Up @@ -640,11 +639,11 @@ protected internal static List<LinkViewNode> GetLinks(ChainNode target)
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static int IComparableStep<ChainingStep>.Compare(ChainingStep left, ChainingStep right)
=> Sign(left.Difficulty - right.Difficulty) is var d and not 0
=> Math.Sign(left.Difficulty - right.Difficulty) is var d and not 0
? d
: Sign(left.Complexity - right.Complexity) is var c and not 0
: Math.Sign(left.Complexity - right.Complexity) is var c and not 0
? c
: Sign(left.SortKey - right.SortKey) is var s and not 0 ? s : 0;
: Math.Sign(left.SortKey - right.SortKey) is var s and not 0 ? s : 0;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Sudoku.Concepts;
using Sudoku.Rendering;
using Sudoku.Text.Notation;
using static System.Math;

namespace Sudoku.Analytics.Steps;

Expand Down Expand Up @@ -70,5 +69,5 @@ [DataMember] int absoluteOffset
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static int IComparableStep<UniqueRectangleStep>.Compare(UniqueRectangleStep left, UniqueRectangleStep right)
=> Sign(left.Code - right.Code) switch { 0 => Sign(left.AbsoluteOffset - right.AbsoluteOffset), var result => result };
=> Math.Sign(left.Code - right.Code) switch { 0 => Math.Sign(left.AbsoluteOffset - right.AbsoluteOffset), var result => result };
}
3 changes: 1 addition & 2 deletions src/Sudoku.Analytics/Concepts/MultipleForcingChains.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections;
using System.Runtime.CompilerServices;
using System.SourceGeneration;
using static System.Math;

namespace Sudoku.Concepts;

Expand Down Expand Up @@ -113,5 +112,5 @@ public void Add(byte cellOrDigit, ChainNode potential)
{
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int Compare(byte x, byte y) => Sign(x - y);
public int Compare(byte x, byte y) => Math.Sign(x - y);
}
3 changes: 1 addition & 2 deletions src/Sudoku.Core/Algorithm/MinLex/MinLexCandidate.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Math;

namespace Sudoku.Algorithm.MinLex;

Expand Down Expand Up @@ -164,7 +163,7 @@ public static void PatCanon(string source, out string result, bool patternOnly =
var pPair = stackalloc GridPattern[2];
GridPattern.FromStringUnsafe(source, pPair);
scoped var minTopRowScores = (ReadOnlySpan<int>)[pPair[0].BestTopRowScore, pPair[1].BestTopRowScore];
var minTopRowScore = Min(minTopRowScores[0], minTopRowScores[1]);
var minTopRowScore = Math.Min(minTopRowScores[0], minTopRowScores[1]);
var resultBuffer = stackalloc byte[82];
resultBuffer[0] = (byte)(minTopRowScore >> 8 & 1);
resultBuffer[1] = (byte)(minTopRowScore >> 7 & 1);
Expand Down
3 changes: 1 addition & 2 deletions src/Sudoku.Core/Algorithm/Solving/DictionaryQuerySolver.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Diagnostics;
using System.Runtime.CompilerServices;
using Sudoku.Concepts;
using static System.Math;

namespace Sudoku.Algorithm.Solving;

Expand Down Expand Up @@ -166,7 +165,7 @@ private bool AllNotNull<T>(IEnumerable<T> sequence)
/// <returns>The final zipped collection.</returns>
private string[][] Zip(string[] a, string[] b)
{
var n = Min(a.Length, b.Length);
var n = Math.Min(a.Length, b.Length);
var sd = new string[n][];

for (var i = 0; i < n; i++)
Expand Down
3 changes: 1 addition & 2 deletions src/Sudoku.Core/Concepts/CandidateMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Sudoku.Concepts.Primitive;
using Sudoku.Linq;
using Sudoku.Text.Notation;
using static System.Math;
using static System.Numerics.BitOperations;
using static Sudoku.SolutionWideReadOnlyFields;

Expand Down Expand Up @@ -403,7 +402,7 @@ public readonly CandidateMap[] GetAllSubsets(int limitSubsetSize)
}

var (n, desiredSize) = (_count, 0);
var length = Min(n, limitSubsetSize);
var length = Math.Min(n, limitSubsetSize);
for (var i = 1; i <= length; i++)
{
desiredSize += PascalTriangle[n - 1][i - 1];
Expand Down
5 changes: 2 additions & 3 deletions src/Sudoku.Core/Concepts/CellMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Sudoku.Concepts.Primitive;
using Sudoku.Linq;
using Sudoku.Text.Notation;
using static System.Math;
using static System.Numerics.BitOperations;
using static Sudoku.SolutionWideReadOnlyFields;

Expand Down Expand Up @@ -565,7 +564,7 @@ public readonly bool InOneHouse(out House houseIndex)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[ExplicitInterfaceImpl(typeof(IComparable<>))]
public readonly int CompareTo(scoped in CellMap other)
=> _count > other._count ? 1 : _count < other._count ? -1 : Sign($"{this:b}".CompareTo($"{other:b}"));
=> _count > other._count ? 1 : _count < other._count ? -1 : Math.Sign($"{this:b}".CompareTo($"{other:b}"));

/// <inheritdoc cref="object.ToString"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down Expand Up @@ -686,7 +685,7 @@ public readonly CellMap[] GetAllSubsets(int limitSubsetSize)
}

var (n, desiredSize) = (_count, 0);
var length = Min(n, limitSubsetSize);
var length = Math.Min(n, limitSubsetSize);
for (var i = 1; i <= length; i++)
{
desiredSize += PascalTriangle[n - 1][i - 1];
Expand Down
5 changes: 2 additions & 3 deletions src/Sudoku.Core/Concepts/GridTransformations.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Runtime.CompilerServices;
using static System.Math;
using static Sudoku.SolutionWideReadOnlyFields;

namespace Sudoku.Concepts;
Expand Down Expand Up @@ -207,15 +206,15 @@ public static ref Grid RotateCounterclockwise(this ref Grid @this)
}

/// <summary>
/// Rotate the grid <c><see cref="PI"/></c> degrees.
/// Rotate the grid <c><see cref="Math.PI"/></c> degrees.
/// </summary>
/// <param name="this">The grid.</param>
/// <returns>The result.</returns>
/// <remarks>
/// This method will return the reference that is same as the argument,
/// in order to inline multiple transformation operations.
/// </remarks>
/// <seealso cref="PI"/>
/// <seealso cref="Math.PI"/>
public static ref Grid RotatePi(this ref Grid @this)
{
var result = Grid.Undefined;
Expand Down
3 changes: 1 addition & 2 deletions src/Sudoku.Core/Concepts/Primitive/IBitStatusMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Runtime.CompilerServices;
using System.SourceGeneration;
using Sudoku.Linq;
using static System.Math;
using static Sudoku.SolutionWideReadOnlyFields;

namespace Sudoku.Concepts.Primitive;
Expand Down Expand Up @@ -306,7 +305,7 @@ public virtual TSelf[] GetAllSubsets(int limitSubsetSize)
}

var (n, desiredSize) = (Count, 0);
var length = Min(n, limitSubsetSize);
var length = Math.Min(n, limitSubsetSize);
for (var i = 1; i <= length; i++)
{
var target = PascalTriangle[n - 1][i - 1];
Expand Down
7 changes: 3 additions & 4 deletions src/Sudoku.Core/Text/Formatting/PencilMarkFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Text;
using Sudoku.Concepts;
using Sudoku.Runtime.MaskServices;
using static System.Math;
using static System.Numerics.BitOperations;

namespace Sudoku.Text.Formatting;
Expand Down Expand Up @@ -98,15 +97,15 @@ public unsafe string ToString(scoped in Grid grid)
candidatesCount += PopCount((uint)value);

// Compares the values.
var comparer = Max(
var comparer = Math.Max(
candidatesCount,
MaskOperations.MaskToCellState(value) switch
{
// The output will be '<digit>' and consist of 3 characters.
CellState.Given => Max(candidatesCount, TreatValueAsGiven is null ? 1 : 3),
CellState.Given => Math.Max(candidatesCount, TreatValueAsGiven is null ? 1 : 3),

// The output will be '*digit*' and consist of 3 characters.
CellState.Modifiable => Max(candidatesCount, TreatValueAsGiven is null ? 1 : 3),
CellState.Modifiable => Math.Max(candidatesCount, TreatValueAsGiven is null ? 1 : 3),

// Normal output: 'series' (at least 1 character).
_ => candidatesCount
Expand Down
3 changes: 1 addition & 2 deletions src/Sudoku.Core/Text/Formatting/SukakuFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.SourceGeneration;
using System.Text;
using Sudoku.Concepts;
using static System.Math;

namespace Sudoku.Text.Formatting;

Expand Down Expand Up @@ -85,7 +84,7 @@ public string ToString(scoped in Grid grid)
var maxLength = 0;
for (var p = 0; p < 9; p++)
{
maxLength = Max(maxLength, builders[p * 9 + column].Length);
maxLength = Math.Max(maxLength, builders[p * 9 + column].Length);
}

span[column] = maxLength;
Expand Down
1 change: 1 addition & 0 deletions src/SudokuStudio/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Windows.Storage;
using Windows.Storage.Pickers;
using WinRT.Interop;
using static SudokuStudio.ProjectWideConstants;

namespace SudokuStudio;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using SudokuStudio.Interaction;
using SudokuStudio.Interaction.Conversions;
using SudokuStudio.Views.Controls;
using static SudokuStudio.Strings.StringsAccessor;

namespace SudokuStudio.BindableSource;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using SudokuStudio.Configuration;
using static SudokuStudio.Strings.StringsAccessor;

namespace SudokuStudio.BindableSource;

Expand Down
4 changes: 2 additions & 2 deletions src/SudokuStudio/Extensions/DragEventArgsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static int GetIndexViaCursorPoint<T>(this DragEventArgs @this, T target)
var itemHeight = sampleItem.ActualHeight + sampleItem.Margin.Top + sampleItem.Margin.Bottom;

// Find index based on dividing number of items by height of each item.
index = Min(target.Items.Count - 1, (int)(pos.Y / itemHeight));
index = Math.Min(target.Items.Count - 1, (int)(pos.Y / itemHeight));

// Find the item being dropped on top of.
var targetItem = (ListViewItem)target.ContainerFromIndex(index);
Expand All @@ -40,7 +40,7 @@ public static int GetIndexViaCursorPoint<T>(this DragEventArgs @this, T target)
}

// Don't go out of bounds.
index = Min(target.Items.Count, index);
index = Math.Min(target.Items.Count, index);
}

return index;
Expand Down
2 changes: 1 addition & 1 deletion src/SudokuStudio/Extensions/PointExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ public static class PointExtensions
/// <returns>The distance of the two points.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double DistanceTo(this Point @this, Point other)
=> Sqrt((@this.X - other.X) * (@this.X - other.X) + (@this.Y - other.Y) * (@this.Y - other.Y));
=> Math.Sqrt((@this.X - other.X) * (@this.X - other.X) + (@this.Y - other.Y) * (@this.Y - other.Y));
}
3 changes: 0 additions & 3 deletions src/SudokuStudio/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
global using static System.Math;
global using static SudokuStudio.ProjectWideConstants;
global using static SudokuStudio.Strings.StringsAccessor;
global using Colors = Microsoft.UI.Colors;
global using DispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue;
global using GridLayout = Microsoft.UI.Xaml.Controls.Grid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Sudoku.Text.Notation;
using SudokuStudio.BindableSource;
using SudokuStudio.Collection;
using static SudokuStudio.Strings.StringsAccessor;

namespace SudokuStudio.Interaction.Conversions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using static SudokuStudio.Strings.StringsAccessor;

namespace SudokuStudio.Interaction.Conversions;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Sudoku.Analytics.Categorization;
using Windows.UI;
using static System.Numerics.BitOperations;
using static SudokuStudio.Strings.StringsAccessor;

namespace SudokuStudio.Interaction.Conversions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using static SudokuStudio.Strings.StringsAccessor;

namespace SudokuStudio.Interaction.Conversions;

internal static class GeneratingStrategyConversion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Sudoku.Algorithm.Solving;
using Sudoku.Concepts;
using Sudoku.Text.Notation;
using static SudokuStudio.Strings.StringsAccessor;

namespace SudokuStudio.Interaction.Conversions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
using Sudoku.Analytics.Categorization;
using static SudokuStudio.Strings.StringsAccessor;

namespace SudokuStudio.Interaction.Conversions;

Expand Down
Loading

0 comments on commit 44f3f4c

Please sign in to comment.