Am Montag, den 27.06.2005, 11:08 -0600 schrieb Tom Tromey:
> >>>>> "Roman" == Roman Kennke <[EMAIL PROTECTED]> writes:
> 
> Roman> +  public static Component[] getVisibleChildren(Container c)
> Roman> +  {
> Roman> +    Component[] children = c.getComponents();
> Roman> +    Vector visible = new Vector();
> Roman> +    for (int i = 0; i < children.length; i++)
> Roman> +      if (children[i].isVisible())
> Roman> +        visible.add(children[i]);
> Roman> +    return (Component[]) visible.toArray(new 
> Container[visible.size()]);
> 
> This means multiple allocations per layout.

I could easily optimize this. I would have to return an implementation
of Collection (or List, for correctness of semantics) that wraps the
Component[] returned by getComponents() and provides an Iterator over
this. This could still mean 2 allocations per layout (one for the List,
one for the collection), but both could probably be cached for later
use.

Do you think this is preferable? Or should the LayoutManagers sort this
out on themselves?

/Roman




_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to