Skip to content

Commit

Permalink
Unrevert two changes
Browse files Browse the repository at this point in the history
* Sorted Delete for TArray
* Typed constructor for TObjPtr
  • Loading branch information
RicardoLuis0 committed Mar 15, 2024
1 parent 0092aa0 commit cc88dfb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/common/objects/dobjgc.h
Expand Up @@ -215,6 +215,9 @@ class TObjPtr
mutable DObject *o;
};
public:
TObjPtr() = default;

TObjPtr(T t) : pp(t) {}

constexpr TObjPtr<T>& operator=(T q) noexcept
{
Expand Down
29 changes: 29 additions & 0 deletions src/common/utility/tarray.h
Expand Up @@ -576,6 +576,35 @@ class TArray
return f;
}

bool SortedDelete(const T& obj)
{
auto f = SortedFind(obj, true);
if (f == Size())
{
Delete(f);
return true;
}
else
{
return false;
}
}

template<typename Func>
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)
Expand Down

0 comments on commit cc88dfb

Please sign in to comment.