From cc88dfbe5015dcf0156450b0d6d6707bed81f1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Fri, 15 Mar 2024 17:19:02 -0300 Subject: [PATCH] Unrevert two changes * Sorted Delete for TArray * Typed constructor for TObjPtr --- src/common/objects/dobjgc.h | 3 +++ src/common/utility/tarray.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/common/objects/dobjgc.h b/src/common/objects/dobjgc.h index f5514255db..280c86273f 100644 --- a/src/common/objects/dobjgc.h +++ b/src/common/objects/dobjgc.h @@ -215,6 +215,9 @@ class TObjPtr mutable DObject *o; }; public: + TObjPtr() = default; + + TObjPtr(T t) : pp(t) {} constexpr TObjPtr& operator=(T q) noexcept { diff --git a/src/common/utility/tarray.h b/src/common/utility/tarray.h index f849e9cca5..b642f3c87e 100644 --- a/src/common/utility/tarray.h +++ b/src/common/utility/tarray.h @@ -576,6 +576,35 @@ public: return f; } + bool SortedDelete(const T& obj) + { + auto f = SortedFind(obj, true); + if (f == Size()) + { + Delete(f); + return true; + } + else + { + return false; + } + } + + template + bool SortedDelete(const T& obj, Func lt) + { + auto f = SortedFind(obj, lt, true); + if (f == Size()) + { + Delete(f); + return true; + } + else + { + return false; + } + } + bool Pop () { if (Count > 0)