mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
24 lines
504 B
C#
24 lines
504 B
C#
#region
|
|
|
|
using System.Collections.Generic;
|
|
|
|
#endregion
|
|
|
|
namespace NewHorizons.Utility
|
|
{
|
|
public static class CollectionUtilities
|
|
{
|
|
public static T KeyByValue<T, W>(Dictionary<T, W> dict, W val)
|
|
{
|
|
T key = default;
|
|
foreach (var pair in dict)
|
|
if (EqualityComparer<W>.Default.Equals(pair.Value, val))
|
|
{
|
|
key = pair.Key;
|
|
break;
|
|
}
|
|
|
|
return key;
|
|
}
|
|
}
|
|
} |