From 709997feb1016fd33a755b94b21c7b7d29a71b27 Mon Sep 17 00:00:00 2001 From: disarray2077 <86157825+disarray2077@users.noreply.github.com> Date: Thu, 24 Jun 2021 20:04:56 -0300 Subject: [PATCH 1/2] Add Remove method to Dictionary Enumerators --- BeefLibs/corlib/src/Collections/Dictionary.bf | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/BeefLibs/corlib/src/Collections/Dictionary.bf b/BeefLibs/corlib/src/Collections/Dictionary.bf index 2bd9cc1f..66a4b312 100644 --- a/BeefLibs/corlib/src/Collections/Dictionary.bf +++ b/BeefLibs/corlib/src/Collections/Dictionary.bf @@ -864,6 +864,13 @@ namespace System.Collections mDictionary.mEntries[mCurrentIndex].mValue = value; } + public void Remove() mut + { + int_cosize curIdx = mIndex - 1; + mDictionary.Remove(mDictionary.mEntries[curIdx].mKey); + mIndex = curIdx; + } + public void Reset() mut { #if VERSION_DICTIONARY @@ -1005,6 +1012,13 @@ namespace System.Collections { } + public void Remove() mut + { + int_cosize curIdx = mIndex - 1; + mDictionary.Remove(mDictionary.mEntries[curIdx].mKey); + mIndex = curIdx; + } + public void Reset() mut { #if VERSION_DICTIONARY @@ -1101,6 +1115,13 @@ namespace System.Collections { } + public void Remove() mut + { + int_cosize curIdx = mIndex - 1; + mDictionary.Remove(mDictionary.mEntries[curIdx].mKey); + mIndex = curIdx; + } + public void Reset() mut { #if VERSION_DICTIONARY From ce894beaa971b9c34fea31a1117f3997f3a10d76 Mon Sep 17 00:00:00 2001 From: disarray2077 <86157825+disarray2077@users.noreply.github.com> Date: Thu, 24 Jun 2021 20:19:47 -0300 Subject: [PATCH 2/2] Update Enumerator version when removing key --- BeefLibs/corlib/src/Collections/Dictionary.bf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/BeefLibs/corlib/src/Collections/Dictionary.bf b/BeefLibs/corlib/src/Collections/Dictionary.bf index 66a4b312..d308fcb4 100644 --- a/BeefLibs/corlib/src/Collections/Dictionary.bf +++ b/BeefLibs/corlib/src/Collections/Dictionary.bf @@ -868,6 +868,9 @@ namespace System.Collections { int_cosize curIdx = mIndex - 1; mDictionary.Remove(mDictionary.mEntries[curIdx].mKey); +#if VERSION_DICTIONARY + mVersion = mDictionary.mVersion; +#endif mIndex = curIdx; } @@ -1016,6 +1019,9 @@ namespace System.Collections { int_cosize curIdx = mIndex - 1; mDictionary.Remove(mDictionary.mEntries[curIdx].mKey); +#if VERSION_DICTIONARY + mVersion = mDictionary.mVersion; +#endif mIndex = curIdx; } @@ -1119,6 +1125,9 @@ namespace System.Collections { int_cosize curIdx = mIndex - 1; mDictionary.Remove(mDictionary.mEntries[curIdx].mKey); +#if VERSION_DICTIONARY + mVersion = mDictionary.mVersion; +#endif mIndex = curIdx; }