Duplicated Iterator class. Each iterator you get by calling isplit or split on a splitted iterator will be of this type.
| 38 | return iteritem |
| 39 | |
| 40 | class _IDupped(object): |
| 41 | """Duplicated Iterator class. Each iterator you get by calling isplit |
| 42 | or split on a splitted iterator will be of this type.""" |
| 43 | |
| 44 | def __init__(self,idup,oldno=-1): |
| 45 | self.__idup = idup |
| 46 | self.__iterno = idup.registerIter(oldno) |
| 47 | |
| 48 | def next(self): |
| 49 | return self.__idup.getNext(self.__iterno) |
| 50 | |
| 51 | def split(self): |
| 52 | """Split this iterator into two pieces. The original iterator |
| 53 | is still callable, as is the sub-iterator.""" |
| 54 | |
| 55 | return _IDupped(self.__idup,self.__iterno) |
| 56 | |
| 57 | def __iter__(self): |
| 58 | return self |
| 59 | |
| 60 | def isplit(iterin,splitno=2): |
| 61 | idup = _IDup(iterin) |