sclass ImmutableSortedList<A> extends AbstractList<A> { O[] array; *() { array = emptyObjectArray(); } *(Collection<? extends A> elements) { main.sort(array = toObjectArray(elements)); } public int size() { ret l(array); } public A get(int i) { ret (A) array[i]; } public int indexOf(O o) { ret max(-1, Arrays.binarySearch(array, o)); } public bool contains(O o) { ret indexOf(o) >= 0; } }
Began life as a copy of #1002392
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1010953 |
Snippet name: | ImmutableSortedList - more compact than a TreeSet |
Eternal ID of this version: | #1010953/7 |
Text MD5: | 59bf608d0772973d417c2e899ab6310d |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-10-10 14:51:40 |
Source code size: | 463 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 439 / 1014 |
Version history: | 6 change(s) |
Referenced in: | [show references] |