cp-library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub kobejean/cp-library

:warning: cp_library/alg/iter/slice_iterator_cls.py

Code

import cp_library.alg.iter.__header__
from cp_library.misc.typing import _T
from typing import Iterator, SupportsIndex

class SliceIterator(Iterator[_T]):
    def __init__(self, A: list[_T], R: list[SupportsIndex]):
        self.A, self.R, self.l, self.i = A, R, 0, 0
    def __len__(self): return len(self.R)-self.i
    def __next__(self):
        R = self.R
        if self.i >= len(R): raise StopIteration
        self.l, l = (r := R[self.i]), self.l
        self.i += 1
        return self.A[l:r]
'''
╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸
             https://kobejean.github.io/cp-library               
'''
from typing import TypeVar
_T = TypeVar('T')
from typing import Iterator, SupportsIndex

class SliceIterator(Iterator[_T]):
    def __init__(self, A: list[_T], R: list[SupportsIndex]):
        self.A, self.R, self.l, self.i = A, R, 0, 0
    def __len__(self): return len(self.R)-self.i
    def __next__(self):
        R = self.R
        if self.i >= len(R): raise StopIteration
        self.l, l = (r := R[self.i]), self.l
        self.i += 1
        return self.A[l:r]
Back to top page