private void deleteEvent(EventRegKeyExpiration regExpiration,EventReg reg){
  listeners.dec();
synchronized (reg) {
    EntryRep[] tmpls=reg.tmpl.attributeSetTemplates;
    if (tmpls != null) {
      for (int i=tmpls.length; --i >= 0; ) {
        EntryClass eclass=tmpls[i].eclass;
        eclass.setNumTemplates(eclass.getNumTemplates() - 1);
      }
    }
    Long id=reg.eventID;
    eventByID.remove(id);
    if (regExpiration != null) {
      eventByTime.remove(regExpiration);
    }
 else {
      eventByTime.remove(new EventRegKeyExpiration(reg,reg.leaseExpiration));
    }
    if (reg.tmpl.serviceID != null) {
      Object val=subEventByService.get(reg.tmpl.serviceID);
      if (val == reg) {
        subEventByService.remove(reg.tmpl.serviceID);
      }
 else {
        Object[] array=(EventReg[])val;
        array=arrayDel(array,indexOf(array,reg));
        if (array.length == 1)         val=array[0];
 else         val=array;
        subEventByService.put(reg.tmpl.serviceID,val);
      }
    }
 else {
      subEventByID.remove(id);
    }
    computeMaxLeases();
  }
}

private void deleteEvent ( EventRegKeyExpiration regExpiration , EventReg reg ) { listeners . dec ( ) ; synchronized ( reg ) { EntryRep [ ] tmpls = reg . tmpl . attributeSetTemplates ; if ( tmpls != null ) { for ( int i = tmpls . length ; -- i >= 0 ; ) { EntryClass eclass = tmpls [ i ] . eclass ; eclass . setNumTemplates ( eclass . getNumTemplates ( ) - 1 ) ; } } Long id = reg . eventID ; eventByID . remove ( id ) ; if ( regExpiration != null ) { eventByTime . remove ( regExpiration ) ; } else { eventByTime . remove ( new EventRegKeyExpiration ( reg , reg . leaseExpiration ) ) ; } if ( reg . tmpl . serviceID != null ) { Object val = subEventByService . get ( reg . tmpl . serviceID ) ; if ( val == reg ) { subEventByService . remove ( reg . tmpl . serviceID ) ; } else { Object [ ] array = ( EventReg [ ] ) val ; array = arrayDel ( array , indexOf ( array , reg ) ) ; if ( array . length == 1 ) val = array [ 0 ] ; else val = array ; subEventByService . put ( reg . tmpl . serviceID , val ) ; } } else { subEventByID . remove ( id ) ; } computeMaxLeases ( ) ; } }
remove an event registration from our state . this includes deleting a template of each entryclass , deleting the registration from the eventbyid map , the eventbytime map , and either the subeventbyservice or subeventbyid map .
