From 5b02c68372e334430cf77fcffd0283524a697f07 Mon Sep 17 00:00:00 2001 From: disarray2077 <86157825+disarray2077@users.noreply.github.com> Date: Wed, 27 Oct 2021 23:29:03 -0300 Subject: [PATCH] Add TryGetValueAlt to Dictionary --- BeefLibs/corlib/src/Collections/Dictionary.bf | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/BeefLibs/corlib/src/Collections/Dictionary.bf b/BeefLibs/corlib/src/Collections/Dictionary.bf index 03135d23..7d0bf19e 100644 --- a/BeefLibs/corlib/src/Collections/Dictionary.bf +++ b/BeefLibs/corlib/src/Collections/Dictionary.bf @@ -739,6 +739,18 @@ namespace System.Collections return false; } + public bool TryGetValueAlt(TAltKey key, out TValue value) where TAltKey : IHashable where bool : operator TKey == TAltKey + { + int_cosize i = (int_cosize)FindEntryAlt(key); + if (i >= 0) + { + value = mEntries[i].mValue; + return true; + } + value = default(TValue); + return false; + } + public bool TryGet(TKey key, out TKey matchKey, out TValue value) { int_cosize i = (int_cosize)FindEntry(key);