src/share/classes/javax/sound/midi/Track.java

Print this page

        

*** 64,77 **** public class Track { // TODO: use arrays for faster access // the list containing the events ! private ArrayList eventsList = new ArrayList(); // use a hashset to detect duplicate events in add(MidiEvent) ! private HashSet set = new HashSet(); private MidiEvent eotEvent; /** --- 64,77 ---- public class Track { // TODO: use arrays for faster access // the list containing the events ! private ArrayList<MidiEvent> eventsList = new ArrayList<>(); // use a hashset to detect duplicate events in add(MidiEvent) ! private HashSet<MidiEvent> set = new HashSet<>(); private MidiEvent eotEvent; /**
*** 106,116 **** int eventsCount = eventsList.size(); // get the last event MidiEvent lastEvent = null; if (eventsCount > 0) { ! lastEvent = (MidiEvent) eventsList.get(eventsCount - 1); } // sanity check that we have a correct end-of-track if (lastEvent != eotEvent) { // if there is no eot event, add our immutable instance again if (lastEvent != null) { --- 106,116 ---- int eventsCount = eventsList.size(); // get the last event MidiEvent lastEvent = null; if (eventsCount > 0) { ! lastEvent = eventsList.get(eventsCount - 1); } // sanity check that we have a correct end-of-track if (lastEvent != eotEvent) { // if there is no eot event, add our immutable instance again if (lastEvent != null) {
*** 146,156 **** // insert event such that events is sorted in increasing // tick order int i = eventsCount; for ( ; i > 0; i--) { ! if (event.getTick() >= ((MidiEvent)eventsList.get(i-1)).getTick()) { break; } } if (i == eventsCount) { // we're adding an event after the --- 146,156 ---- // insert event such that events is sorted in increasing // tick order int i = eventsCount; for ( ; i > 0; i--) { ! if (event.getTick() >= (eventsList.get(i-1)).getTick()) { break; } } if (i == eventsCount) { // we're adding an event after the
*** 218,228 **** * @return the event at the specified index */ public MidiEvent get(int index) throws ArrayIndexOutOfBoundsException { try { synchronized(eventsList) { ! return (MidiEvent)eventsList.get(index); } } catch (IndexOutOfBoundsException ioobe) { throw new ArrayIndexOutOfBoundsException(ioobe.getMessage()); } } --- 218,228 ---- * @return the event at the specified index */ public MidiEvent get(int index) throws ArrayIndexOutOfBoundsException { try { synchronized(eventsList) { ! return eventsList.get(index); } } catch (IndexOutOfBoundsException ioobe) { throw new ArrayIndexOutOfBoundsException(ioobe.getMessage()); } }
*** 251,261 **** */ public long ticks() { long ret = 0; synchronized (eventsList) { if (eventsList.size() > 0) { ! ret = ((MidiEvent)eventsList.get(eventsList.size() - 1)).getTick(); } } return ret; } --- 251,261 ---- */ public long ticks() { long ret = 0; synchronized (eventsList) { if (eventsList.size() > 0) { ! ret = (eventsList.get(eventsList.size() - 1)).getTick(); } } return ret; }