Refactor internal and external API for ports
Current situation:
- direct manipulation of input ports and output ports possible because internal array is published
Requirements:
- use a List interface
- iterate as fast as with arrays
Solution proposal:
interface PortList<T, P extends AbstractPort<T>> {
int size();
void each(Consumer<T> consumer); // iterates all elements starting at 0
void each(Consumer<T> consumer, int startIndex); // iterates all elements starting at startIndex; really necessary?
P next(Next next);
boolean hasAnyOpenPort();
}
interface DynamicPortList<T, P extends AbstractPort<T>> extends PortList<T, P> {
/** returns the new index of the given port */
int add(P port);
void remove(int index);
}
interface Next {
int nextIndex(); // returns the next index to be used
}
- Next for
RoundRobinStrategy
andRemovePortAction