bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/29088] New: AbstractCollection should aviod calls to size


From: subanark at gmail dot com
Subject: [Bug classpath/29088] New: AbstractCollection should aviod calls to size()
Date: 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()
           Product: classpath
           Version: 0.93
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: classpath
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: subanark at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29088





reply via email to

[Prev in Thread] Current Thread [Next in Thread]