Sized (original) (raw)
Brian Goetz brian.goetz at oracle.com
Tue Nov 27 19:46:39 PST 2012
- Previous message: Sized
- Next message: Sized
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I still think the only way out is to introduce a new method with long return type. We could even do it while keeping the name Sized, but leaving the size() method alone for continued use in Collections-only applications, and defaulting the new method in Collection:
OK, but...
public interface Sized { // or pick a new name /** * Returns the number of elements */ long elementCount(); // oh no, another arbitrary name choice
default boolean isEmpty() { return elementCount() == 0; } } interface Collection extends Sized ... { default long elementCount() { return (long)size(); } ... }
...why would you have the new method not return the actual size, rather than the clamped size returned by size()?
- Previous message: Sized
- Next message: Sized
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the lambda-libs-spec-observers mailing list