Libraryless. Click here for Pure Java version (5409L/30K).
1 | svoid testMoreEfficientCopyOnWriteList() { |
2 | new MoreEfficientCopyOnWriteList<Int> l; |
3 | var it = l.iterator(); |
4 | l.add(5); |
5 | assertEquals(ll(), asList(it)); |
6 | it = l.iterator(); |
7 | l.add(0, 10); |
8 | assertEquals(ll(5), asList(it)); |
9 | assertEquals(ll(10, 5), asList(l.iterator())); |
10 | |
11 | // make sure this doesn't take O(n^2) time |
12 | time "My list" { repeat 20000 { l.add(0); } } |
13 | |
14 | // ...while this does |
15 | new CopyOnWriteArrayList<Int> l2; |
16 | time "Their list" { repeat 20000 { l2.add(0); } } |
17 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034558 |
Snippet name: | testMoreEfficientCopyOnWriteList |
Eternal ID of this version: | #1034558/3 |
Text MD5: | 7ec3a38e58d3b863fa35df03a1ac31ab |
Transpilation MD5: | 820890cb0d72042b833fcf355f252687 |
Author: | stefan |
Category: | javax / collections |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-02-13 18:43:32 |
Source code size: | 506 bytes / 17 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 131 / 191 |
Version history: | 2 change(s) |
Referenced in: | [show references] |