Sized (original) (raw)
Brian Goetz brian.goetz at oracle.com
Fri Nov 2 15:05:33 PDT 2012
- Previous message: Cancelable streams
- Next message: Sized
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
We've been using a placeholder interface Sized in the Streams API, for two reasons:
- It is useful to indicate that an aggregate knows its size (Collections do, but not all Iterables do, and we've taken advantage of this in the Streams library)
- It provides a piece of the story for the migration to 64-bit collections.
Here's how this migration story might work. Today, we have:
interface Sized { int size(); default long longSize() { return size(); } }
and add it as a new supertype of Collection.
Then (now or later) we can add a subtype:
interface LongSized extends Sized { default int size() { long size = longSize(); if (size > Integer.MAX_VALUE) throw something; return (int) size; }
long longSize(); // reabstraction
}
Then, 64-bit-aware collections can implement LongSized.
- Previous message: Cancelable streams
- Next message: Sized
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the lambda-libs-spec-observers mailing list