> I think that for methods that if used normally do not throw exceptions,
> checks should be done by exception if possible. For example in
> ArrayEnumeration, possibility that nextElement() overflows is very small
> (every sane person use hasNextElement() first). So, code could look like
> this:
>
> try {
> return elements[index++];
> } catch ( ArrayOutOfBoundsException e ) {
> throw new NoSuchElementException();
> }
>
> instead of
>
> if ( index >= elements.length ) throw ...
> return elements[index++];
You're right. However, ArrayEnumeration should be removed from the tree
anyway, as its functionality is available elsewhere.
>
>
> 2) Vector:addAll(Collection)
> is: ensureCapacity(c.size())
> should be: ensureCapacity(c.size() + elementCount)
This has been fixed already. In the new code, addAll(Collection) calls
addAll(index, Collection) which had the correct ensureCapacity line. But
good catch.
> and the we could use
> elements[elementCount++]=i.next();
> instead of
> addElement(i.next())
> (of course it is just matter of efficiency - it was working)
The above fixed that as well. I wrote the initial code to work, and
hadn't made an optimization pass. Again, good point though.
>
>
> 3) I think, that if it is possible, class specific utility classes
> should be implemented as inner classes
> (for example VectorIterator). They could be static or non-static, but it
> just looks better (at least for me).
Man, you are just one step behind. Stuard Ballard pointed out that
AbstractList handled the Iterator and ListIterator stuff already (Look in
AbstractList under the iterator() and listIterator() methods, so those
classes got axed. :)
> >
>
> Note that all this things are just style/efficiency remarks - java.util
> is done well, and certainly good design and robustness is more important
> that chasing few opcodes of speedup.
Ah yes, but those few opcodes make you feel that much better.
Scott
--------------------------------------------------------------------------
Java Programmer Scott Gregory Miller Linux afficionado
Graphics Designer [EMAIL PROTECTED] General Loony
--------------------------------------------------------------------------