From dd7a84ef0376b45ebeae88d1402bec65dae10291 Mon Sep 17 00:00:00 2001 From: disarray2077 <86157825+disarray2077@users.noreply.github.com> Date: Fri, 18 Feb 2022 11:53:17 -0300 Subject: [PATCH] Add `GetAndRemoveStrict` to `List` --- BeefLibs/corlib/src/Collections/List.bf | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/BeefLibs/corlib/src/Collections/List.bf b/BeefLibs/corlib/src/Collections/List.bf index 02d7d1a5..c334560b 100644 --- a/BeefLibs/corlib/src/Collections/List.bf +++ b/BeefLibs/corlib/src/Collections/List.bf @@ -812,6 +812,19 @@ namespace System.Collections return .Err; } + public Result GetAndRemoveStrict(T item) + { + int index = IndexOfStrict(item); + if (index >= 0) + { + T val = mItems[index]; + RemoveAt(index); + return val; + } + + return .Err; + } + public Result GetAndRemoveAlt(TAlt item) where TAlt : IHashable where bool : operator T == TAlt { int index = IndexOfAlt(item);