1 | !include #1001196 // Lisp |
2 | |
3 | static class SList { |
4 | new L<S> data; // don't access this from outside |
5 | |
6 | // these are ok to access (but not change) from outside |
7 | final S id = randomID(8); |
8 | final L<Lisp> history = synchroList(); |
9 | |
10 | public synchronized void add(S a) { |
11 | data.add(a); |
12 | history.add(lisp("add", a)); |
13 | } |
14 | |
15 | public synchronized void clear() { |
16 | data.clear(); |
17 | history.add(lisp("clear")); |
18 | } |
19 | |
20 | public synchronized void remove(int i) { |
21 | data.remove(i); |
22 | history.add(lisp("remove", "" + i)); |
23 | } |
24 | |
25 | public synchronized void remove(S s) { |
26 | int i = data.indexOf(s); |
27 | if (i >= 0) remove(i); |
28 | } |
29 | |
30 | public synchronized int indexOf(S s) { |
31 | return data.indexOf(s); |
32 | } |
33 | |
34 | public synchronized S get(int i) { |
35 | return data.get(i); |
36 | } |
37 | |
38 | public S getID() { |
39 | return id; |
40 | } |
41 | |
42 | public synchronized int size() { |
43 | return data.size(); |
44 | } |
45 | } |
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: | #1001414 |
Snippet name: | SList (a synchronized string list with history) |
Eternal ID of this version: | #1001414/1 |
Text MD5: | 06b8da37a2ae0db2e4084d789c8b2bdd |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-10-15 18:18:42 |
Source code size: | 931 bytes / 45 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 603 / 833 |
Referenced in: | [show references] |