[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/29088] New: AbstractCollection should aviod calls to size
subanark at gmail dot com
[Bug classpath/29088] New: AbstractCollection should aviod calls to size()
14 Sep 2006 17:46:10 -0000
The "optimization" of calling size instead of calling hasNext(), in various
methods in AbstractCollection may not in fact be an optimization. Implementers
may have an expensive size() implementations if the value is not cached, or it
simply may not be implemented. Using the Sun JDK and not implementing size()
(simply throwing an exception) will not break other methods that
AbstractionCollection defines except for the toArray methods.
Consider the case where data is being lazily added to a collection. The
iterator may block until data becomes avialable when next() is called. While
size() would have to block until all data is avialable.
Suggestion: Use iterator.hasNext() for each loop iteration instead of size().
Summary: AbstractCollection should aviod calls to size()
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: subanark at gmail dot com
|[Prev in Thread]
||[Next in Thread]|
- [Bug classpath/29088] New: AbstractCollection should aviod calls to size(),
subanark at gmail dot com <=