mirror of
https://github.com/facebookresearch/blt.git
synced 2025-01-18 16:37:46 +00:00
24 lines
480 B
Python
24 lines
480 B
Python
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
import abc
|
|
from typing import Any, Generator, Generic, TypeVar
|
|
|
|
T = TypeVar("T")
|
|
C = TypeVar("C")
|
|
|
|
|
|
class StatefulIterator(Generic[T, C], abc.ABC):
|
|
|
|
@abc.abstractmethod
|
|
def get_state(self) -> C:
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def create_iter(self) -> Generator[T, Any, None]:
|
|
pass
|
|
|
|
|
|
class IteratorState(Generic[C]):
|
|
@abc.abstractmethod
|
|
def build(self) -> StatefulIterator[T, C]:
|
|
pass
|