Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.3.0 #106

Merged
merged 6 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.3.0] - 2023-10-25
### Added
- Add `IModInt<T>.Value` and `IModInt<T>.Mod`
### Changed
- Move `IStaticMod` to IModInterface.cs
### Removed
- Remove DebugView from expanded code

## [3.2.0] - 2023-09-25
### Added
- Add `Deque<T>.Grow(int capacity)`
Expand Down
6 changes: 4 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<RepositoryUrl>https://github.com/kzrnm/ac-library-csharp</RepositoryUrl>
<PackageReleaseNotes>https://github.com/kzrnm/ac-library-csharp/blob/main/CHANGELOG.md</PackageReleaseNotes>

<Version>3.2.0</Version>
<AssemblyVersion>3.2.0.101</AssemblyVersion>
<Version>3.3.0</Version>
<AssemblyVersion>3.3.0.101</AssemblyVersion>
<RepositoryCommit Condition="'$(GIT_COMMIT)' != ''">$(GIT_COMMIT)</RepositoryCommit>

<SignAssembly>True</SignAssembly>
Expand All @@ -19,6 +19,8 @@
<EmbeddingSource>true</EmbeddingSource>
<DefineConstants Condition="'$(EmbeddingSource)'=='true'">$(DefineConstants);EMBEDDING</DefineConstants>

<SourceExpanderVersion>5.5.1</SourceExpanderVersion>

<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ public TValue Sum(int r)
[MethodImpl(256)]
public TValue Slice(int l, int len) => Sum(l, l + len);

#if EMBEDDING
[SourceExpander.NotEmbeddingSource]
#endif
[DebuggerDisplay("Value = {" + nameof(Value) + "}, Sum = {" + nameof(Sum) + "}")]
internal readonly struct DebugItem
{
Expand All @@ -101,6 +103,9 @@ public DebugItem(TValue value, TValue sum)
public TValue Value { get; }
public TValue Sum { get; }
}
#if EMBEDDING
[SourceExpander.NotEmbeddingSource]
#endif
private class DebugView
{
private readonly FenwickTree<TValue> fw;
Expand All @@ -109,7 +114,6 @@ public DebugView(FenwickTree<TValue> fenwickTree)
fw = fenwickTree;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
[SourceExpander.NotEmbeddingSource]
public DebugItem[] Items
{
get
Expand Down
6 changes: 5 additions & 1 deletion Source/ac-library-csharp/DataStructure/FenwickTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ public TValue Sum(int r)
[MethodImpl(256)]
public TValue Slice(int l, int len) => Sum(l, l + len);

#if EMBEDDING
[SourceExpander.NotEmbeddingSource]
#endif
[DebuggerDisplay("Value = {" + nameof(Value) + "}, Sum = {" + nameof(Sum) + "}")]
internal readonly struct DebugItem
{
Expand All @@ -107,6 +109,9 @@ public DebugItem(TValue value, TValue sum)
public TValue Value { get; }
public TValue Sum { get; }
}
#if EMBEDDING
[SourceExpander.NotEmbeddingSource]
#endif
private class DebugView
{
private readonly FenwickTree<TValue, TOp> fw;
Expand All @@ -115,7 +120,6 @@ public DebugView(FenwickTree<TValue, TOp> fenwickTree)
fw = fenwickTree;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
[SourceExpander.NotEmbeddingSource]
public DebugItem[] Items
{
get
Expand Down
6 changes: 5 additions & 1 deletion Source/ac-library-csharp/DataStructure/LazySegtree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ public int MinLeft(int r, Predicate<TValue> g)
return 0;
}

#if EMBEDDING
[SourceExpander.NotEmbeddingSource]
#endif
[DebuggerDisplay("Value = {" + nameof(Value) + "}, Lazy = {" + nameof(Lazy) + "}", Name = "{" + nameof(Key) + ",nq}")]
internal readonly struct DebugItem
{
Expand All @@ -369,6 +371,9 @@ public DebugItem(int l, int r, TValue value, F lazy)
public TValue Value { get; }
public F Lazy { get; }
}
#if EMBEDDING
[SourceExpander.NotEmbeddingSource]
#endif
private class DebugView
{
private readonly LazySegtree<TValue, F, TOp> s;
Expand All @@ -377,7 +382,6 @@ public DebugView(LazySegtree<TValue, F, TOp> segtree)
s = segtree;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
[SourceExpander.NotEmbeddingSource]
public DebugItem[] Items
{
get
Expand Down
6 changes: 5 additions & 1 deletion Source/ac-library-csharp/DataStructure/Segtree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ public int MinLeft(int r, Predicate<TValue> f)
return 0;
}

#if EMBEDDING
[SourceExpander.NotEmbeddingSource]
#endif
[DebuggerDisplay("{" + nameof(Value) + "}", Name = "{" + nameof(Key) + ",nq}")]
internal readonly struct DebugItem
{
Expand All @@ -270,6 +272,9 @@ public DebugItem(int l, int r, TValue value)
public string Key => R - L == 1 ? $"[{L}]" : $"[{L}-{R})";
public TValue Value { get; }
}
#if EMBEDDING
[SourceExpander.NotEmbeddingSource]
#endif
private class DebugView
{
private readonly Segtree<TValue, TOp> s;
Expand All @@ -278,7 +283,6 @@ public DebugView(Segtree<TValue, TOp> segtree)
s = segtree;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
[SourceExpander.NotEmbeddingSource]
public DebugItem[] Items
{
get
Expand Down
29 changes: 0 additions & 29 deletions Source/ac-library-csharp/Math/ModInt/IModInt.cs

This file was deleted.

78 changes: 78 additions & 0 deletions Source/ac-library-csharp/Math/ModInt/IModInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#if GENERIC_MATH
using System.Numerics;
#endif

namespace AtCoder
{
public interface IModInt<T>
#if GENERIC_MATH
: INumberBase<T> where T : INumberBase<T>
#endif
{
/// <summary>
/// 自身を x として、 xy≡1 なる y を返します。
/// </summary>
/// <remarks>
/// <para>制約: gcd(x, mod) = 1</para>
/// </remarks>
T Inv();

/// <summary>
/// 自身を x として、x^<paramref name="n"/> を返します。
/// </summary>
/// <remarks>
/// <para>制約: 0≤|<paramref name="n"/>|</para>
/// <para>計算量: O(log(<paramref name="n"/>))</para>
/// </remarks>
T Pow(ulong n);

/// <summary>
/// 格納されている値を返します。
/// </summary>
int Value { get; }

#if GENERIC_MATH
/// <summary>
/// mod を返します。
/// </summary>
abstract static int Mod { get; }
#endif
}

/// <summary>
/// コンパイル時に決定する mod を表します。
/// </summary>
/// <example>
/// <code>
/// public readonly struct Mod1000000009 : IStaticMod
/// {
/// public uint Mod => 1000000009;
/// public bool IsPrime => true;
/// }
/// </code>
/// </example>
[IsOperator]
public interface IStaticMod
{
/// <summary>
/// mod を取得します。
/// </summary>
uint Mod { get; }

/// <summary>
/// mod が素数であるか識別します。
/// </summary>
bool IsPrime { get; }
}
public readonly struct Mod1000000007 : IStaticMod
{
public uint Mod => 1000000007;
public bool IsPrime => true;
}

public readonly struct Mod998244353 : IStaticMod
{
public uint Mod => 998244353;
public bool IsPrime => true;
}
}
42 changes: 2 additions & 40 deletions Source/ac-library-csharp/Math/ModInt/StaticModInt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,6 @@

namespace AtCoder
{
/// <summary>
/// コンパイル時に決定する mod を表します。
/// </summary>
/// <example>
/// <code>
/// public readonly struct Mod1000000009 : IStaticMod
/// {
/// public uint Mod => 1000000009;
/// public bool IsPrime => true;
/// }
/// </code>
/// </example>
[IsOperator]
public interface IStaticMod
{
/// <summary>
/// mod を取得します。
/// </summary>
uint Mod { get; }

/// <summary>
/// mod が素数であるか識別します。
/// </summary>
bool IsPrime { get; }
}
public readonly struct Mod1000000007 : IStaticMod
{
public uint Mod => 1000000007;
public bool IsPrime => true;
}

public readonly struct Mod998244353 : IStaticMod
{
public uint Mod => 998244353;
public bool IsPrime => true;
}

/// <summary>
/// 四則演算時に自動で mod を取る整数型。mod の値はコンパイル時に決定している必要があります。
/// </summary>
Expand All @@ -61,9 +24,8 @@ public interface IStaticMod
/// }
/// </code>
/// </example>
public readonly struct StaticModInt<T>
: IEquatable<StaticModInt<T>>, IFormattable, IModInt<StaticModInt<T>>
where T : struct, IStaticMod
public readonly struct StaticModInt<T> : IEquatable<StaticModInt<T>>, IFormattable, IModInt<StaticModInt<T>>
where T : struct, IStaticMod
{
internal readonly uint _v;
private static readonly T op = default;
Expand Down
4 changes: 4 additions & 0 deletions Source/ac-library-csharp/STL/PriorityQueue/PriorityQueueOp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ protected internal void UpdateDown(int i)

[EditorBrowsable(Never)]
public ReadOnlySpan<T> Unorderd() => data.AsSpan(0, Count);

#if EMBEDDING
[SourceExpander.NotEmbeddingSource]
#endif
private class DebugView
{
private readonly PriorityQueueOp<T, TOp> pq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ protected internal void UpdateDown(int i)
public ReadOnlySpan<TKey> UnorderdKeys() => keys.AsSpan(0, Count);
[EditorBrowsable(Never)]
public ReadOnlySpan<TValue> UnorderdValues() => values.AsSpan(0, Count);

#if EMBEDDING
[SourceExpander.NotEmbeddingSource]
#endif
private class DebugView
{
private readonly PriorityQueueOp<TKey, TValue, TKOp> pq;
Expand Down
2 changes: 1 addition & 1 deletion Source/ac-library-csharp/ac-library-csharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<OutputItemType>Analyzer</OutputItemType>
</ProjectReference>
<PackageReference Include="SourceExpander.Embedder" Version="5.3.1" Condition="'$(EmbeddingSource)'=='true'">
<PackageReference Include="SourceExpander.Embedder" Version="$(SourceExpanderVersion)" Condition="'$(EmbeddingSource)'=='true'">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
25 changes: 25 additions & 0 deletions Test/Expand.Test/Expand.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net7.0;netcoreapp3.1</TargetFrameworks>
<Nullable>annotations</Nullable>

<LangVersion Condition="'$(TargetFramework)' == 'netcoreapp3.1'">8</LangVersion>
<LangVersion Condition="'$(TargetFramework)' == 'net7.0'">11</LangVersion>

<NoWarn>$(NoWarn);CS0436;CS8981;CS0649</NoWarn>
<SourceExpander_Generator_ExpandingAll>true</SourceExpander_Generator_ExpandingAll>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SourceExpander.Generator" Version="$(SourceExpanderVersion)">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Source\ac-library-csharp\ac-library-csharp.csproj" />
</ItemGroup>
</Project>
9 changes: 9 additions & 0 deletions Test/Expand.Test/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
partial class Program
{
static void Main()
{
#if EMBEDDING
System.Console.WriteLine(SourceExpander.Testing.AtCoder.MathLib.PowMod(255, 1L << 52, 12));
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<ItemGroup>
<PackageReference Include="Competitive.IO" Version="1.0.1" />
<PackageReference Include="CompetitiveVerifierProblem" Version="1.4.0" />
<PackageReference Include="CompetitiveVerifierProblem" Version="1.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading