Files
UnrealEngineUWP/Engine/Source/Programs/UnrealBuildTool/Utilities/DictionaryExtensions.cs
Ben Marsh 149375b14b Update copyright notices to 2015.
[CL 2379638 by Ben Marsh in Main branch]
2014-12-07 19:09:38 -05:00

31 lines
702 B
C#

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
using System.Collections.Generic;
namespace UnrealBuildTool
{
public static class DictionaryExtensions
{
public static Value GetOrAddDefault<Key, Value>(this IDictionary<Key, Value> Dict, Key InKey)
{
Value Result;
if( !Dict.TryGetValue( InKey, out Result ) )
{
Result = default(Value);
Dict.Add( InKey, Result );
}
return Result;
}
public static Value GetOrAddNew<Key, Value>(this IDictionary<Key, Value> Dict, Key InKey) where Value : new()
{
Value Result;
if( !Dict.TryGetValue( InKey, out Result ) )
{
Result = new Value();
Dict.Add( InKey, Result );
}
return Result;
}
}
}