Libraryless. Click here for Pure Java version (3679L/22K).
1 | sclass AscendingOrderIntObjectMap<A> { |
2 | new IntBuffer keys; |
3 | new L<A> values; |
4 | |
5 | void put(int key, A value) { |
6 | if (!keys.isEmpty() && last(keys) >= key) |
7 | fail("Ascending order fail: " + last(keys) + " / " + key); |
8 | keys.add(key); |
9 | values.add(value); |
10 | } |
11 | |
12 | A get(int key) { |
13 | int i = intBufferBinarySearch(keys, key); |
14 | ret i >= 0 ? values.get(i) : null; |
15 | } |
16 | |
17 | int size() { ret keys.size(); } |
18 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1031750 |
Snippet name: | AscendingOrderIntObjectMap - you can only put keys in ascending order |
Eternal ID of this version: | #1031750/2 |
Text MD5: | fd3d7963a2b62f8e8d1e3c91b11ed451 |
Transpilation MD5: | da1ef4d15316a203e19db817619dcb4c |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-29 04:38:48 |
Source code size: | 437 bytes / 18 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 247 / 403 |
Version history: | 1 change(s) |
Referenced in: | [show references] |