// a map of assignments that can be rolled back to some state static class SNLMatches { new HashMap<S, Lisp> map; new L<S> log; boolean put(S key, Lisp val) { if (map.containsKey(key)) // existing ret eq(map.get(key), val); // new map.put(key, val); log.add(key); ret true; } Lisp get(S key) { ret map.get(key); } S raw(S key) { Lisp x = get(key); if (x == null) fail("var not set: " + key); ret x.raw(); } boolean containsKey(S key) { ret map.containsKey(key); } int save() { ret l(log); } void restore(int i) { while (l(log) > i) { S key = log.get(l(log)-1); map.remove(key); log.remove(l(log)-1); } } boolean addAll(SNLMatches m) { for (S var : m.keySet()) if (!put(var, m.get(var))) ret false; ret true; } Set<S> keySet() { ret map.keySet(); } }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1002748 |
| Snippet name: | class SNLMatches |
| Eternal ID of this version: | #1002748/1 |
| Text MD5: | 10b4588d4ea13249689a55a58425efda |
| Author: | stefan |
| Category: | eleu / nl |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-02-25 01:31:58 |
| Source code size: | 974 bytes / 53 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 992 / 2248 |
| Referenced in: | [show references] |