collections: SequencedDemo put through the reversed view now actually breaks the order (zed=60)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KqJyCidz3ZgRyHABv2GVJh
This commit is contained in:
@@ -3,7 +3,7 @@ reversed() : {erin=95, alice=90, carol=85, bob=70}
|
||||
firstEntry() : bob=70
|
||||
lastEntry() : erin=95
|
||||
top2 (by pos) : [erin=95, alice=90]
|
||||
after put via view (no longer sorted): {bob=70, carol=85, alice=90, erin=95, zed=99}
|
||||
putLast/putFirst : {carol=85, alice=90, erin=95, zed=99, bob=70}
|
||||
TreeMap first : alice=90 reversed: {zed=99, erin=95, carol=85, bob=70, alice=90}
|
||||
pollFirstEntry: carol=85 -> {alice=90, erin=95, zed=99, bob=70}
|
||||
after put via view (no longer sorted): {bob=70, carol=85, alice=90, erin=95, zed=60}
|
||||
putLast/putFirst : {carol=85, alice=90, erin=95, zed=60, bob=70}
|
||||
TreeMap first : alice=90 reversed: {zed=60, erin=95, carol=85, bob=70, alice=90}
|
||||
pollFirstEntry: carol=85 -> {alice=90, erin=95, zed=60, bob=70}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
-------------------------------------------------------------------------------
|
||||
Test set: com.ankurm.collections.SortingTest
|
||||
-------------------------------------------------------------------------------
|
||||
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.229 s -- in com.ankurm.collections.SortingTest
|
||||
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.238 s -- in com.ankurm.collections.SortingTest
|
||||
|
||||
@@ -27,7 +27,7 @@ public class SequencedDemo {
|
||||
System.out.println("top2 (by pos) : " + top2);
|
||||
|
||||
// Because it is a view, writes show through.
|
||||
asc.reversed().put("zed", 99);
|
||||
asc.reversed().put("zed", 60);
|
||||
System.out.println("after put via view (no longer sorted): " + asc);
|
||||
|
||||
// Re-ordering an existing LinkedHashMap: putLast moves an existing key to the end.
|
||||
|
||||
Reference in New Issue
Block a user