diff options
author | Alice Ryhl <aliceryhl@google.com> | 2025-06-16 10:36:21 +0000 |
---|---|---|
committer | Miguel Ojeda <ojeda@kernel.org> | 2025-06-29 18:52:41 +0200 |
commit | fbcd4b7bf5c92f7d456eefcecac518023357cea4 (patch) | |
tree | 412e7a16837627164159f907fa6d3ab445f7133f /rust/kernel/str.rs | |
parent | 0303584766b7bdb6564c7e8f13e0b59b6ef44984 (diff) |
rust: rbtree: add RBTree::is_empty
In Rust Binder I need to be able to determine whether a red/black tree
is empty. Thus, add a method for that operation to replace
rbtree.iter().next().is_none()
This is terrible, so add a method for this purpose. We do not add a
RBTree::len method because computing the number of elements requires
iterating the entire tree, but checking whether it is empty can be done
cheaply.
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Link: https://lore.kernel.org/r/20250616-rbtree-is-empty-v1-1-61f7cfb012e3@google.com
[ Adjusted title. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/kernel/str.rs')
0 files changed, 0 insertions, 0 deletions