1 | sclass ImmutableSortedList<A> extends AbstractList<A> { |
2 | O[] array; |
3 | |
4 | *() { array = emptyObjectArray(); } |
5 | *(Collection<? extends A> elements) { |
6 | main.sort(array = toObjectArray(elements)); |
7 | } |
8 | |
9 | public int size() { ret l(array); } |
10 | |
11 | public A get(int i) { |
12 | ret (A) array[i]; |
13 | } |
14 | |
15 | public int indexOf(O o) { |
16 | ret max(-1, Arrays.binarySearch(array, o)); |
17 | } |
18 | |
19 | public bool contains(O o) { |
20 | ret indexOf(o) >= 0; |
21 | } |
22 | } |
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: | 440 / 1016 |
Version history: | 6 change(s) |
Referenced in: | [show references] |