> Would it be possible that Sequence<T> extends Iterable<T>? So that you can 
> use any Sequence instance in a for-each loop, not just some specialized 
> subclasses such as TablePane.ColumnSequence.

List<T> is meant to serve this purpose. List<T> extends Sequence<T> and 
Collection<T>, which extends Iterable<T>. Similarly, Map<K, V> extends 
Dictionary<K, V> and Collection<K>, and Set<E> extends Group<E> and 
Collection<E>. This approach allows us to combine collection behaviors without 
collisions on the Iterable type (for example, org.apache.pivot.xml.Element 
implements List<Node> and Dictionary<String, String>, which wouldn't compile if 
Dictionary also implemented Iterable).

We use Sequence rather than List in our inner classes primarily because we want 
the associated mutator events to be fired from the outer class, rather than the 
sequence itself, as we would need to do if the sequences implemented List (they 
would need to fire ListListener events).


Reply via email to