<s> DEFAULT = <NUM_LIT:0> <EOL> NO_ELEMENT = - <NUM_LIT:1> <EOL> class Cursor ( object ) : <EOL> def __init__ ( self , net ) : <EOL> self . net = net <EOL> self . next_iter = None <EOL> self . threads = [ ] <EOL> self . to_start ( ) <EOL> def next ( self ) : <EOL> if not self . next_iter : <EOL> self . next_iter = self . net <EOL> self . threads = [ i for i in self . next_iter . parall_elem ] <EOL> else : <EOL> if self . threads : <EOL> return self . threads . pop ( ) <EOL> if self . next_iter . next_element [ <NUM_LIT:0> ] : <EOL> if self . next_iter . num_element < len ( <EOL> self . next_iter . next_element ) : <EOL> self . __change_state_cursor ( self . next_iter . num_element ) <EOL> else : <EOL> self . __change_state_cursor ( DEFAULT ) <EOL> else : <EOL> self . next_iter = NO_ELEMENT <EOL> if self . next_iter == NO_ELEMENT : <EOL> raise StopIteration <EOL> return self . next_iter <EOL> def __change_state_cursor ( self , num_element ) : <EOL> self . next_iter = self . next_iter . next_element [ num_element ] <EOL> self . threads = [ i for i in self . next_iter . parall_elem ] <EOL> def __iter__ ( self ) : <EOL> return self <EOL> def current ( self ) : <EOL> return self . net <EOL> @ staticmethod <EOL> def forward_back ( net ) : <EOL> obj = net <EOL> while obj . prev_element : <EOL> obj = obj . prev_element <EOL> return obj <EOL> def to_start ( self ) : <EOL> obj = self . forward_back ( self . net ) <EOL> self . net = obj <EOL> self . next_iter = None <EOL> return obj </s>
