<commit_before>interface IEvent<T> {
  GlobalId add(EventHandler<T> handler);
  bool remove(GlobalId id);
}

class PEvent<T> implements IEvent<T> {
  final HashMap<GlobalId, EventHandler<T>> _handlers;

  PEvent._internal() : _handlers = new HashMap<GlobalId, EventHandler<T>>();
  
  GlobalId add(EventHandler<T> handler){
    var id = new GlobalId();
    _handlers[id] = handler;
    return id;
  }

  bool remove(GlobalId id){
    return _handlers.remove(id) != null;
  }
  
  void _fireEvent(Object sender, T args){
    _handlers.forEach((GlobalId id, EventHandler<T> handler){
      handler(sender, args);
    });
  }
}

class EventArgs {
  const EventArgs();
}

class EventHandle<T> {
  final PEvent<T> event;
  
  EventHandle() : event = new PEvent<T>._internal();

  void fireEvent(Object sender, T args){
    event._fireEvent(sender, args);
  }
}

typedef EventHandler<T>(Object sender, T args);<commit_msg>PEvent: todo, handlercount on EventHandle<commit_after>interface IEvent<T> {
  GlobalId add(EventHandler<T> handler);
  bool remove(GlobalId id);
}

class PEvent<T> implements IEvent<T> {
  final HashMap<GlobalId, EventHandler<T>> _handlers;

  PEvent._internal() : _handlers = new HashMap<GlobalId, EventHandler<T>>();
  
  GlobalId add(EventHandler<T> handler){
    var id = new GlobalId();
    _handlers[id] = handler;
    return id;
  }

  bool remove(GlobalId id){
    return _handlers.remove(id) != null;
  }
  
  void _fireEvent(Object sender, T args){
    _handlers.forEach((GlobalId id, EventHandler<T> handler){
      handler(sender, args);
    });
  }
}

class EventArgs {
  const EventArgs();
}

class EventHandle<T> {
  // TODO: ponder creating event instance on-demand
  final PEvent<T> event;
  
  EventHandle() : event = new PEvent<T>._internal();

  void fireEvent(Object sender, T args){
    event._fireEvent(sender, args);
  }

  int get handlerCount(){
    return event._handlers.length;
  }
}

typedef EventHandler<T>(Object sender, T args);
{'fraction_non_alphanumeric': 0.13094034378159758, 'fraction_numerical': 0.0, 'mean_word_length': 4.074358974358974, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1823823', 'n_tokens_mistral': 667, 'n_tokens_neox': 657, 'n_words': 162}