code: public int getEventCount(long referenceTime) {
          int count = 0;
          for (Event<T> event : queue) {
              if (event.getTimestamp() <= referenceTime) {
                  ++count;
              }
          }
          return count;
      }
docs: Scans the event queue and returns number of events having
  timestamp less than or equal to the reference time.
  
  @param referenceTime the reference timestamp in millis
  @return the count of events with timestamp less than or equal to referenceTime