Add all missing docs
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
namespace PkmnLib.Static.Utils;
|
||||
|
||||
/// <summary>
|
||||
/// Helpers for working with dictionaries.
|
||||
/// </summary>
|
||||
public static class DictionaryHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the value for a key in a dictionary, or returns a default value if the key is not found.
|
||||
/// </summary>
|
||||
public static TValue GetOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key,
|
||||
TValue defaultValue)
|
||||
{
|
||||
if (dictionary.TryGetValue(key, out var value))
|
||||
return value;
|
||||
return defaultValue;
|
||||
}
|
||||
TValue defaultValue) =>
|
||||
dictionary.TryGetValue(key, out var value) ? value : defaultValue;
|
||||
}
|
||||
@@ -34,6 +34,9 @@ public static class EnumerableHelpers
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all elements from a list that match the given predicate.
|
||||
/// </summary>
|
||||
public static void RemoveAll<T>(this IList<T> list, Func<T, bool> predicate)
|
||||
{
|
||||
for (var i = list.Count - 1; i >= 0; i--)
|
||||
|
||||
@@ -50,12 +50,18 @@ public static class NumericHelpers
|
||||
return result > short.MaxValue ? short.MaxValue : (short)result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies two values. If this overflows, returns <see cref="uint.MaxValue"/>.
|
||||
/// </summary>
|
||||
public static uint MultiplyOrMax(this uint value, uint multiplier)
|
||||
{
|
||||
var result = (ulong)value * multiplier;
|
||||
return result > uint.MaxValue ? uint.MaxValue : (uint)result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies two values. If this overflows, returns <see cref="uint.MaxValue"/>.
|
||||
/// </summary>
|
||||
public static uint MultiplyOrMax(this uint value, float multiplier)
|
||||
{
|
||||
var result = value * multiplier;
|
||||
|
||||
Reference in New Issue
Block a user