RFR: 8266571: Sequenced Collections [v10]
Stuart Marks
smarks at openjdk.org
Tue Apr 25 00:10:32 UTC 2023
On Sat, 22 Apr 2023 09:33:57 GMT, ExE Boss <duke at openjdk.org> wrote:
>> Stuart Marks has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Wording tweaks to SequencedMap / NavigableMap.
>> - Change "The implementation in this class" to "... interface."
>
> src/java.base/share/classes/java/util/SortedMap.java line 113:
>
>> 111: */
>> 112:
>> 113: public interface SortedMap<K,V> extends SequencedMap<K,V> {
>
> This interface can now provide default implementations for the `firstKey` and `lastKey` methods:
>
> default K firstKey() {
> var entry = this.firstEntry();
> if (entry == null) {
> throw new NoSuchElementException();
> }
> return entry.getKey();
> }
>
>
> default K lastKey() {
> var entry = this.lastEntry();
> if (entry == null) {
> throw new NoSuchElementException();
> }
> return entry.getKey();
> }
Doesn't seem all that useful.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r1175895948
More information about the core-libs-dev
mailing list