From 4ed8d6d2413d55989dc1faf83481b45241c2dc13 Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 20 May 2026 22:02:44 -0400 Subject: [PATCH] feat: get first or last element of `OneToManyUniqueBTreeMap` --- src/one_to_many.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/one_to_many.rs b/src/one_to_many.rs index c17f9c2..f986b30 100644 --- a/src/one_to_many.rs +++ b/src/one_to_many.rs @@ -42,6 +42,14 @@ where self.right_to_left.get(right) } + pub fn first_left_and_rights(&self) -> Option<(&Left, &BTreeSet)> { + self.left_to_rights.first_key_value() + } + + pub fn last_left_and_rights(&self) -> Option<(&Left, &BTreeSet)> { + self.left_to_rights.last_key_value() + } + pub fn remove_left(&mut self, left: &Left) -> Option<(Left, BTreeSet)> { let (left, rights) = self.left_to_rights.remove_entry(left)?;