This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static class Mem | |
{ | |
public static int PopCount<T>(in T[] values) where T : unmanaged => PopCount<T>(values.AsSpan()); | |
public static int PopCount<T>(in ReadOnlySpan<T> values) where T : unmanaged | |
{ | |
#pragma warning disable S907 | |
var count = 0; | |
var bytes = MemoryMarshal.AsBytes(values); | |
ref var current = ref MemoryMarshal.GetReference(bytes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Diagnostics; | |
public sealed class FpsCounter | |
{ | |
double currentFps; | |
long lastFrameTime; | |
const float SmoothFactor = 0.1f; | |
public FpsCounter() => Reset(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Easing | |
{ | |
#pragma warning disable S1121 | |
public static float Linear(float k) => k; | |
public static class Quadratic | |
{ | |
public static float In(float k) => k * k; | |
public static float Out(float k) => k * (2f - k); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public readonly struct Fixed : | |
IEquatable<Fixed>, | |
IComparable<Fixed>, | |
IFormattable, IUtf8SpanFormattable, | |
IComparisonOperators<Fixed, Fixed, bool>, | |
IAdditionOperators<Fixed, Fixed, Fixed>, | |
ISubtractionOperators<Fixed, Fixed, Fixed>, | |
IIncrementOperators<Fixed>, | |
IDecrementOperators<Fixed> | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Runtime.CompilerServices; | |
Check(Foo.A | Foo.B | Foo.C, Foo.B); | |
Check(Foo.A | Foo.B, Foo.C); | |
Check(Foo.A | Foo.C, Foo.None); | |
Check(Foo.A | Foo.B | Foo.C, Foo.B | Foo.C); | |
Check(Foo.A | Foo.B | Foo.D, Foo.B | Foo.C); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using System.Threading; | |
using System.Threading.Channels; | |
using System.Collections.Concurrent; | |
using System.Collections.Generic; | |
using System.Runtime.CompilerServices; | |
using System.Diagnostics; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Buffers; | |
using System.Runtime.CompilerServices; | |
// ReSharper disable ParameterHidesMember | |
sealed unsafe class NativeMemoryManager<T> : MemoryManager<T> | |
where T : unmanaged | |
{ | |
byte* pointer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Disposable static functions | |
/// </summary> | |
public static class Disposable | |
{ | |
/// <inheritdoc /> | |
/// <summary> | |
/// Create new deferred context | |
/// </summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
SortedHashSet<int> values = []; | |
Console.WriteLine("Start"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Numerics; | |
Print(13u); | |
Print(12L); | |
Print<short>(2); | |
Print<UInt128>(2); | |
static void Print<T>(T p) |
NewerOlder