43 lines
832 B
C#
43 lines
832 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Text.RegularExpressions;
|
|
using System.Text;
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using System.IO;
|
|
using System.Diagnostics;
|
|
using Godot;
|
|
|
|
using Rokojori.Extensions;
|
|
namespace Rokojori.Extensions;
|
|
|
|
public static class DictionaryExtensions
|
|
{
|
|
public static V GetOr<K,V>( this Dictionary<K,V> map, K key, V orValue )
|
|
{
|
|
if ( map.ContainsKey( key ) )
|
|
{
|
|
return map[ key ];
|
|
}
|
|
|
|
return orValue;
|
|
}
|
|
|
|
public static void ForEach<K,V>( this Dictionary<K,V> map, Action<K,V> callback )
|
|
{
|
|
foreach ( var item in map )
|
|
{
|
|
callback( item.Key, item.Value );
|
|
}
|
|
}
|
|
|
|
public static void ForEachKey<K,V>( this Dictionary<K,V> map, Action<K> callback )
|
|
{
|
|
foreach ( var item in map )
|
|
{
|
|
callback( item.Key );
|
|
}
|
|
}
|
|
}
|