diff --git a/cheuph/element_supply.py b/cheuph/element_supply.py index 2818720..85d3da7 100644 --- a/cheuph/element_supply.py +++ b/cheuph/element_supply.py @@ -74,6 +74,14 @@ class ElementSupply(ABC, Generic[E]): pass + @abstractmethod + def oldest_id(self) -> Optional[Id]: + """ + Return the smallest id. + """ + + pass + def root_id(self, elem_id: Id) -> Id: """ Find the root of the tree that an element is contained in. @@ -288,3 +296,10 @@ class InMemorySupply(ElementSupply[E]): return roots[-1] else: return None + + def oldest_id(self) -> Optional[Id]: + ids = self._elements.keys() + if ids: + return min(ids) + else: + return None