Iterator over a standalone algorithm sequence
This custom class is needed to implement a "recursive iteration", which
would loop over all algorithms in a sequence that itself may have
sub-sequences inside of it.
Definition at line 234 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.
◆ __init__()
def python.AlgSequence.AlgSequenceIterator.__init__ |
( |
|
self, |
|
|
|
sequence |
|
) |
| |
Constructor for the algorithm sequence iterator
Keyword arguments:
sequence -- The sequence to iterate over (recursively)
Definition at line 242 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.
243 """Constructor for the algorithm sequence iterator
246 sequence -- The sequence to iterate over (recursively)
250 self._sequence = sequence
252 self._iterator =
None
◆ __iter__()
def python.AlgSequence.AlgSequenceIterator.__iter__ |
( |
|
self | ) |
|
◆ __next__()
def python.AlgSequence.AlgSequenceIterator.__next__ |
( |
|
self | ) |
|
Function implementing the recursive iteration over an AlgSequence
This is where most of the logic is. The iterator loops over the
elements of the AlgSequence that was given to it, one by one. When
it finds an element in the AlgSequence that itself is also an
AlgSequence, then it creates a helper iterator object that would
process that sub-sequence, and continue the iteration using that
helper.
The end result is that the iteration should loop over every
algorithm in the sequence and its sub-sequences.
Definition at line 261 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.
261 def __next__( self ):
262 """Function implementing the recursive iteration over an AlgSequence
264 This is where most of the logic is. The iterator loops over the
265 elements of the AlgSequence that was given to it, one by one. When
266 it finds an element in the AlgSequence that itself is also an
267 AlgSequence, then it creates a helper iterator object that would
268 process that sub-sequence, and continue the iteration using that
271 The end result is that the iteration should loop over every
272 algorithm in the sequence and its sub-sequences.
276 if self._index >= len( self._sequence ):
277 raise StopIteration()
283 return self._iterator.__next__()
284 except StopIteration:
289 self._iterator =
None
290 return self.__next__()
295 element = self._sequence[ self._index ]
299 if isinstance( element, AlgSequence ):
300 self._iterator = AlgSequenceIterator( element )
301 return self.__next__()
◆ _index
python.AlgSequence.AlgSequenceIterator._index |
|
private |
◆ _iterator
python.AlgSequence.AlgSequenceIterator._iterator |
|
private |
◆ _sequence
python.AlgSequence.AlgSequenceIterator._sequence |
|
private |
The documentation for this class was generated from the following file: