[refactor] converted Rocket.listenerList from ArrayList -> HashSet
This commit is contained in:
parent
336b899a06
commit
1ec588dff4
@ -1,11 +1,6 @@
|
|||||||
package net.sf.openrocket.rocketcomponent;
|
package net.sf.openrocket.rocketcomponent;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.EventListener;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -39,7 +34,7 @@ public class Rocket extends ComponentAssembly {
|
|||||||
/**
|
/**
|
||||||
* List of component change listeners.
|
* List of component change listeners.
|
||||||
*/
|
*/
|
||||||
private List<EventListener> listenerList = new ArrayList<>();
|
private Set<EventListener> listenerList = new HashSet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When freezeList != null, events are not dispatched but stored in the list.
|
* When freezeList != null, events are not dispatched but stored in the list.
|
||||||
@ -332,7 +327,7 @@ public class Rocket extends ComponentAssembly {
|
|||||||
copy.stageMap = new HashMap<Integer, AxialStage>();
|
copy.stageMap = new HashMap<Integer, AxialStage>();
|
||||||
copy.configSet = new FlightConfigurableParameterSet<FlightConfiguration>( this.configSet );
|
copy.configSet = new FlightConfigurableParameterSet<FlightConfiguration>( this.configSet );
|
||||||
copy.selectedConfiguration = copy.configSet.get( this.getSelectedConfiguration().getId());
|
copy.selectedConfiguration = copy.configSet.get( this.getSelectedConfiguration().getId());
|
||||||
copy.listenerList = new ArrayList<EventListener>();
|
copy.listenerList = new HashSet<EventListener>();
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
@ -397,7 +392,7 @@ public class Rocket extends ComponentAssembly {
|
|||||||
*/
|
*/
|
||||||
public void resetListeners() {
|
public void resetListeners() {
|
||||||
// System.out.println("RESETTING LISTENER LIST of Rocket "+this);
|
// System.out.println("RESETTING LISTENER LIST of Rocket "+this);
|
||||||
listenerList = new ArrayList<EventListener>();
|
listenerList = new HashSet<EventListener>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -413,18 +408,16 @@ public class Rocket extends ComponentAssembly {
|
|||||||
@Override
|
@Override
|
||||||
public void addComponentChangeListener(ComponentChangeListener l) {
|
public void addComponentChangeListener(ComponentChangeListener l) {
|
||||||
checkState();
|
checkState();
|
||||||
if( ! listenerList.contains(l)) {
|
|
||||||
listenerList.add(l);
|
listenerList.add(l);
|
||||||
}
|
|
||||||
log.trace("Added ComponentChangeListener " + l + ", current number of listeners is " +
|
log.trace("Added ComponentChangeListener " + l + ", current number of listeners is " + listenerList.size());
|
||||||
listenerList.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeComponentChangeListener(ComponentChangeListener l) {
|
public void removeComponentChangeListener(ComponentChangeListener l) {
|
||||||
listenerList.remove(l);
|
listenerList.remove(l);
|
||||||
log.trace("Removed ComponentChangeListener " + l + ", current number of listeners is " +
|
log.trace("Removed ComponentChangeListener " + l + ", current number of listeners is " + listenerList.size());
|
||||||
listenerList.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user