def collect(self, items, matcher: TGAbstractMatcher,
             transformer: TGAbstractBaseTransformer):
     results = []
     for item in items:
         if matcher.is_match(item):
             results.append(transformer.transform(item))
     return results
 def react_to_first_match(self,
                          items,
                          matcher: TGAbstractMatcher,
                          reaction: TGAbstractReaction,
                          on_no_match=DO_NOTHING):
     for item in items:
         if matcher.is_match(item):
             reaction.react_to(item)
             return
     on_no_match.execute()
 def any_satisfy(self, items, matcher: TGAbstractMatcher):
     for item in items:
         if matcher.is_match(item):
             return True
     return False
 def select(self, items, matcher: TGAbstractMatcher):
     results = []
     for item in items:
         if matcher.is_match(item):
             results.append(item)
     return results
 def react_to_matches(self, items, matcher: TGAbstractMatcher,
                      reaction: TGAbstractReaction):
     for item in items:
         if matcher.is_match(item):
             reaction.react_to(item)
 def first_match(self, items, matcher: TGAbstractMatcher, default_item):
     for item in items:
         if matcher.is_match(item):
             return item
     return default_item
 def count(self, items, matcher: TGAbstractMatcher):
     count = 0
     for item in items:
         if matcher.is_match(item):
             count += 1
     return count