mirror of
https://github.com/AdAstra-LD/DS-Pokemon-Rom-Editor.git
synced 2026-05-11 14:34:21 -05:00
32 lines
1.2 KiB
C#
32 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace DSPRE {
|
|
public static class Extensions {
|
|
public static int IndexOfNumber(this string str) {
|
|
return str.IndexOfAny("0123456789".ToCharArray());
|
|
}
|
|
public static bool ContainsNumber(this string str) {
|
|
return str.IndexOfNumber() > 0;
|
|
}
|
|
public static Dictionary<string, ushort> Reverse (this Dictionary<ushort, string> source) {
|
|
var dictionary = new Dictionary<string, ushort>();
|
|
foreach (var entry in source) {
|
|
string newKey = entry.Value.ToLower();
|
|
if (!dictionary.ContainsKey(newKey)) {
|
|
dictionary.Add(newKey, entry.Key);
|
|
}
|
|
}
|
|
return dictionary;
|
|
}
|
|
//public static Dictionary<TValue, TKey> Reverse<TKey, TValue>(this IDictionary<TKey, TValue> source) {
|
|
// var dictionary = new Dictionary<TValue, TKey>();
|
|
// foreach (var entry in source) {
|
|
// if (!dictionary.ContainsKey(entry.Value)) {
|
|
// dictionary.Add(entry.Value, entry.Key);
|
|
// }
|
|
// }
|
|
// return dictionary;
|
|
//}
|
|
}
|
|
}
|