Runtime/Libraries/Humility/Query/HUMQuery_Root.cs
/// <summary>
/// Removes all unused values from one dictionary, that don't exist in another.
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
Removes all unused values from one dictionary, that don't exist in another.
Removes all unused values from one dictionary that don ' t exist in another .
public static void Undefine<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, Dictionary<TKey, TValue> deserializedDictionary, Action<TValue> onRemoved)
        {
            var keys = deserializedDictionary.Keys.ToList();
            var values = deserializedDictionary.Values.ToList();
            for (int i = 0; i < deserializedDictionary.Count; i++)
            {
                if (!dictionary.ContainsKey(keys[i]))
                {
                    var value = deserializedDictionary[keys[i]];
                    deserializedDictionary.Remove(keys[i]);
                    onRemoved(value);
                }
            }
        }
public static void Undefine < TKey , TValue > ( this Dictionary < TKey , TValue > dictionary , Dictionary < TKey , TValue > deserializedDictionary , Action < TValue > onRemoved ) { var keys = deserializedDictionary . Keys . ToList ( ) ; var values = deserializedDictionary . Values . ToList ( ) ; for ( int i = 0 ; i < deserializedDictionary . Count ; i ++ ) { if ( ! dictionary . ContainsKey ( keys [ i ] ) ) { var value = deserializedDictionary [ keys [ i ] ] ; deserializedDictionary . Remove ( keys [ i ] ) ; onRemoved ( value ) ; } } }
Removes all unused values from one dictionary, that don't exist in another.
Removes all unused values from one dictionary that don ' t exist in another .
Dictionary<TKey, TValue>
this
deserializedDictionary
Dictionary<TKey, TValue>
onRemoved
Action<TValue>
typeparam
None
typeparam
None