Find oldest message in supply

This commit is contained in:
Joscha 2019-06-09 14:43:49 +00:00
parent 45bf3ecdb0
commit 5e7089f320

View file

@ -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