Question regarding interface java.util.Sized

Mike Duigou mike.duigou at
Fri Oct 26 09:24:26 PDT 2012

We do plan to move Sized to the concrete types rather than interfaces. It's appearance on the interfaces was short term convenience.


On Oct 26 2012, at 06:45 , Kasper Nielsen wrote:

> On Fri, Oct 26, 2012 at 1:54 PM, Gernot Neppert <mcnepp02 at> wrote:
>> Hello all,
>> while browsing the latest lambda-related sourcecode, I came across the
>> new mixin-style interface "java.util.Sized".
>> The JavaDoc says:
>> "Implementing this interface allows an object to indicate that its
>> elements may be efficiently counted."
>> OK, so what do we do with this interface? In what contexts do we want
>> to test for "instanceof Sized" and then query its size()?
>> As far as I can see, "Sized" is implemented by:
>> java.util.Collection
>> java.util.Map
>> java.util.streams.ops.Node
> Yes, I still don't understand why Collection (and Map) implements
> Sized. It should be on the actual implementation of the interface.
> For example, the size operation of ConcurrentLinkedQueue is O(n) but
> it still implements Sized (via Queue extends Collection).
> I find it pretty conflicting with the statement from the Sized
> interface "Counting is always less than O(n)."
> - Kasper

More information about the lambda-dev mailing list