feat: get first or last (left) element with data of OneToManyUniqueBTreeMapWithData

This commit is contained in:
2026-05-23 20:49:44 -04:00
parent 97763877d8
commit e1aab0a8fb

View File

@@ -40,7 +40,7 @@ where
old
}
pub fn get_rights_for(&self, left: &Left) -> Option<&BTreeMap<Right, RightData>> {
pub fn get_rights_and_data_for(&self, left: &Left) -> Option<&BTreeMap<Right, RightData>> {
self.left_to_rights.get(left)
}
@@ -48,9 +48,17 @@ where
self.right_to_left.get(right)
}
pub fn first_left_and_rights_and_data(&self) -> Option<(&Left, &BTreeMap<Right, RightData>)> {
self.left_to_rights.first_key_value()
}
pub fn last_left_and_rights_and_data(&self) -> Option<(&Left, &BTreeMap<Right, RightData>)> {
self.left_to_rights.last_key_value()
}
pub fn get_left_and_data_for(&self, right: &Right) -> Option<(&Left, &RightData)> {
let left = self.right_to_left.get(right)?;
let rights = self.get_rights_for(left)?;
let rights = self.get_rights_and_data_for(left)?;
let right_data = rights.get(right)?;