Find oldest message in supply
This commit is contained in:
parent
45bf3ecdb0
commit
5e7089f320
1 changed files with 15 additions and 0 deletions
|
|
@ -74,6 +74,14 @@ class ElementSupply(ABC, Generic[E]):
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def oldest_id(self) -> Optional[Id]:
|
||||||
|
"""
|
||||||
|
Return the smallest id.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
def root_id(self, elem_id: Id) -> Id:
|
def root_id(self, elem_id: Id) -> Id:
|
||||||
"""
|
"""
|
||||||
Find the root of the tree that an element is contained in.
|
Find the root of the tree that an element is contained in.
|
||||||
|
|
@ -288,3 +296,10 @@ class InMemorySupply(ElementSupply[E]):
|
||||||
return roots[-1]
|
return roots[-1]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def oldest_id(self) -> Optional[Id]:
|
||||||
|
ids = self._elements.keys()
|
||||||
|
if ids:
|
||||||
|
return min(ids)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue