Framework changed to WPF

Only the basic window frame is implemented.
Adjusted the structure of resource files.
This commit is contained in:
2022-09-29 21:56:43 +08:00
parent 346a68ddb4
commit a055dc5299
128 changed files with 48325 additions and 63581 deletions

View File

@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
namespace GrasscutterTools.Utils
{
public class SparseSet
{
private struct Range
{
public int Min;
public int Max;
public Range(int min, int max)
{
Min = min;
Max = max;
}
public bool Check(int value) =>
Min <= value && value <= Max;
}
private readonly List<Range> rangeEntries;
private readonly HashSet<int> denseEntries;
public SparseSet(string csv)
{
rangeEntries = new List<Range>();
denseEntries = new HashSet<int>();
foreach (var token in csv.Replace("\n", "").Replace(" ", "").Split(','))
{
var tokens = token.Split('-');
switch (tokens.Length)
{
case 1:
denseEntries.Add(int.Parse(tokens[0]));
break;
case 2:
rangeEntries.Add(new Range(int.Parse(tokens[0]), int.Parse(tokens[1])));
break;
default:
throw new ArgumentException($"Invalid token passed to SparseSet initializer - {token} (split length {tokens.Length})");
}
}
}
public bool Contains(int i)
{
foreach (var range in rangeEntries)
if (range.Check(i))
return true;
return denseEntries.Contains(i);
}
}
}