feat(util/rb_tree): add max (element) method
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
a47dada27f
commit
658e0780a6
1 changed files with 10 additions and 0 deletions
|
@ -207,6 +207,15 @@ class rb_tree : public CMP {
|
|||
return &it->m_value;
|
||||
}
|
||||
|
||||
static T const * max(node const & n) {
|
||||
node_cell const * it = n.m_ptr;
|
||||
if (!it)
|
||||
return nullptr;
|
||||
while (it->m_right)
|
||||
it = it->m_right.m_ptr;
|
||||
return &it->m_value;
|
||||
}
|
||||
|
||||
node erase(node && n, T const & v) {
|
||||
lean_assert(n);
|
||||
node h = ensure_unshared(n.steal());
|
||||
|
@ -349,6 +358,7 @@ public:
|
|||
}
|
||||
|
||||
T const * min() const { return min(m_root); }
|
||||
T const * max() const { return max(m_root); }
|
||||
bool contains(T const & v) const { return find(v) != nullptr; }
|
||||
|
||||
template<typename F>
|
||||
|
|
Loading…
Add table
Reference in a new issue