<s> from collections import defaultdict <EOL> class PresenceRegister : <EOL> def __init__ ( self ) : <EOL> self . register = defaultdict ( set ) <EOL> self . present = set ( ) <EOL> def notify ( self , event , listener_id , id ) : <EOL> pass <EOL> def add ( self , arrived_id ) : <EOL> self . present . add ( arrived_id ) <EOL> for listener_id in self . register [ arrived_id ] : <EOL> self . notify ( '<STR_LIT>' , listener_id , arrived_id ) <EOL> def remove ( self , left_id ) : <EOL> self . present . remove ( left_id ) <EOL> for listener_id in self . register [ left_id ] : <EOL> self . notify ( '<STR_LIT>' , listener_id , left_id ) <EOL> def register_interest ( self , listener_id , id ) : <EOL> self . register [ id ] . add ( listener_id ) <EOL> if id in self . present : <EOL> self . notify ( '<STR_LIT>' , listener_id , id ) </s>
