code: public synchronized EventData[] getEvents(int event_type) {
          ArrayList<EventData> v = new ArrayList<EventData>();
          for (EventData event : events)
              if (event.event_type == event_type)
                  v.add(event);
          EventData[] periodic = new EventData[v.size()];
          for (int i = 0; i < v.size(); i++) {
              periodic[i] = v.get(i);
              events.remove(v.get(i));
          }
          return periodic;
      }
docs: ==========================================================================