!include #1001196 // Lisp static class AList<A> implements Iterable<A> { new L<A> data; // don't access this from outside // these are ok to access (but not change) from outside final S id = randomID(8); final L<Lisp> history = synchroList(); public synchronized void add(A a) { data.add(a); history.add(lisp("add", structure(a))); } public synchronized void clear() { data.clear(); history.add(lisp("clear")); } public synchronized void remove(int i) { data.remove(i); history.add(lisp("remove", "" + i)); } public synchronized void remove(A a) { int i = data.indexOf(a); if (i >= 0) remove(i); } public synchronized int indexOf(A a) { return data.indexOf(a); } public synchronized A get(int i) { return data.get(i); } public S getID() { return id; } public synchronized int size() { return data.size(); } public synchronized Iterator<A> iterator() { ret new ArrayList<A>(data).iterator(); } public synchronized List<A> shoot() { ret new ArrayList<A>(data); } }
Began life as a copy of #1001414
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: | #1001495 |
Snippet name: | AList (a synchronized object list with history) |
Eternal ID of this version: | #1001495/1 |
Text MD5: | 8ec9f01afcc0ce6630453be106f5bca6 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-10-20 23:50:49 |
Source code size: | 1152 bytes / 53 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 615 / 772 |
Referenced in: | [show references] |