GeneralUtilities

A collection of general utilities useful for other projects,
typically in form of extension methods or static methods.
.Maths namespace
Note: overloads for other numeric types exist when applicable, including BigInteger.
Method (MoreMath) |
Summary |
(extension) int.PosMod |
Calculates modulo (% but always positive) |
(extension) int.Wrap |
Wraps value into given range |
(extension) int.GetFactors |
Performs integer factorization |
MoreMath.Lerp |
Linearly interpolates between 2 values |
MoreMath.InverseLerp |
Inverse of Lerp (returns lerp %-age form value) |
MoreMath.TabShift |
Returns column position of a character after tab |
MoreMath.AngleDifference |
Calculates the shortest distance between 2 angles |
(extension) float.DegToRad |
Converts angle in degrees to radians |
(extension) float.RadToDeg |
Converts angle in radians to degrees |
(extension) BigInteger.Sqrt |
Returns a square root of BigInteger as double |
Method (RadixMath) |
Summary |
(extension) int.DigitalRoot |
Calculates digital root (repeated digit sum) |
(extension) int.ToDigits |
Converts a value into an array of digits |
RadixMath.FromDigits |
Converts an array of digits into a value |
RadixMath.BigIntegerFromDigits |
Same as FromDigits but returns a BigInteger |
RadixMath.CountAllAscending |
Enumerates all numbers with a given places count |
.Collections namespace
Method (GeneralEnumerableExtensions) |
Summary |
(extension) T.Yield<T> |
Wraps anything in a IEnumerable<T> |
(extension) IEnumerable<T>.JoinString |
A fluent way to call string.Join |
(extension) char[].JoinString |
A fluent way to call string constructor |
(extension) T[].SplitIntoSegments |
"Splits" array into ArraySegment<T>s |
This package also implements some methods that were added in .NET7 as extensions for .NET6
.NET6 Extension Method (ReadOnlyExtensions) |
Summary |
IList<T>.AsReadOnly |
Constructs a ReadOnlyCollection<T> |
IDictionary<TKey, TValue>.AsReadOnly |
Constructs a ReadOnlyDictionary<T> |
.Randomness namespace
| Class |
Summary |
ShuffleIndexMap |
The index map of a shuffle (to track where items ended up) |
Method (RandomnessExtensions) |
Summary |
(extension) Random.NextUInt31 |
Returns a random int in range of [0, int.MaxValue] |
(extension) Random.NextByte |
Returns a random byte |
(extension) Random.Chance |
Returns true with %-chance |
(extension) Random.GetItem |
Randomly picks an item from a list or span |
(extension) Random.GetDifferentItems |
Randomly picks multiple different items |
(extension) Random.Shuffle |
Shuffles items in-place |
(extension) Random.ShuffleRemap |
Shuffles items in-place & returns ShuffleIndexMap |
Alternatively, some of the above methods can be invoked as extensions on collections to allow fluent syntax:
| Collection extension method |
Above equivalent |
IReadOnlyList<T>.PickRandom |
Random.GetItem |
IReadOnlyCollection<T>.PickMultipleDifferent |
Random.GetDifferentItems |
IList<T>.Shuffle |
Random.Shuffle |
IList<T>.ShuffleRemap |
Random.ShuffleRemap |
.Reflection namespace
The .Reflection namespace contains reflections extensions and a generic enum ↔ integer converter.
Method (EnumConverter<TEnum,TInt>) |
Summary |
EnumConverter<TEnum,TInt>.ToInt |
Converts an enum value to an integral type |
EnumConverter<TEnum,TInt>.ToEnum |
Converts an integral value to an enum type |
Method (ReflectionExtensions) |
Summary |
(extension) Type.IsSubclassOrSelfOf |
Checks if a type is base type or subclass of it |
(extension) MethodInfo.IsOverride |
Checks if a method is an override |
(extension) IEnumerable.Cast |
A Cast overload with a System.Type parameter |
* Reminder that extension methods are static methods and can be used as such.
| Product |
Versions
Compatible and additional computed target framework versions.
|
|
.NET
|
net6.0
net6.0 is compatible.
net6.0-android
net6.0-android was computed.
net6.0-ios
net6.0-ios was computed.
net6.0-maccatalyst
net6.0-maccatalyst was computed.
net6.0-macos
net6.0-macos was computed.
net6.0-tvos
net6.0-tvos was computed.
net6.0-windows
net6.0-windows was computed.
net7.0
net7.0 was computed.
net7.0-android
net7.0-android was computed.
net7.0-ios
net7.0-ios was computed.
net7.0-maccatalyst
net7.0-maccatalyst was computed.
net7.0-macos
net7.0-macos was computed.
net7.0-tvos
net7.0-tvos was computed.
net7.0-windows
net7.0-windows was computed.
net8.0
net8.0 is compatible.
net8.0-android
net8.0-android was computed.
net8.0-browser
net8.0-browser was computed.
net8.0-ios
net8.0-ios was computed.
net8.0-maccatalyst
net8.0-maccatalyst was computed.
net8.0-macos
net8.0-macos was computed.
net8.0-tvos
net8.0-tvos was computed.
net8.0-windows
net8.0-windows was computed.
net9.0
net9.0 was computed.
net9.0-android
net9.0-android was computed.
net9.0-browser
net9.0-browser was computed.
net9.0-ios
net9.0-ios was computed.
net9.0-maccatalyst
net9.0-maccatalyst was computed.
net9.0-macos
net9.0-macos was computed.
net9.0-tvos
net9.0-tvos was computed.
net9.0-windows
net9.0-windows was computed.
net10.0
net10.0 was computed.
net10.0-android
net10.0-android was computed.
net10.0-browser
net10.0-browser was computed.
net10.0-ios
net10.0-ios was computed.
net10.0-maccatalyst
net10.0-maccatalyst was computed.
net10.0-macos
net10.0-macos was computed.
net10.0-tvos
net10.0-tvos was computed.
net10.0-windows
net10.0-windows was computed.
|
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Rephidock.GeneralUtilities:
GitHub repositories
This package is not used by any popular GitHub repositories.
- Added Random.NextByte extension method
- Doc fixes
- Internal updates