1 | // Should only have one per Concepts because of add logs |
2 | concept PersistentLister implements ILister { |
3 | new HashMap<S, L> lists; |
4 | new HashMap<S, Map> treeMaps; |
5 | new HashMap<S, Map> hashMaps; |
6 | new HashMap<S, Set> treeSets; |
7 | new HashMap<S, IVar> vars; |
8 | transient bool nonSaving; |
9 | |
10 | public L getList(S name) { |
11 | ret getList(name, ll()); |
12 | } |
13 | |
14 | public synchronized L getList(S name, L defaultList) { |
15 | L l = lists.get(name); |
16 | if (l == null) { |
17 | lists.put(name, l = listInConcept(this, cloneList(defaultList))); |
18 | change(); |
19 | } |
20 | ret l; |
21 | } |
22 | |
23 | public synchronized IVar getVar(S name, O defaultValue) { |
24 | IVar v = vars.get(name); |
25 | if (v == null) { |
26 | vars.put(name, v = varInConcept(this, new Var)); |
27 | change(); |
28 | } |
29 | if (!v.has() && defaultValue != null) |
30 | v.set(defaultValue); |
31 | ret v; |
32 | } |
33 | |
34 | public synchronized Map getTreeMap(S name) { |
35 | Map m = treeMaps.get(name); |
36 | if (m == null) { |
37 | treeMaps.put(name, m = mapInConcept(this, new TreeMap)); |
38 | change(); |
39 | } |
40 | if (getOpt_raw(m, 'm) == null) |
41 | fail("map not sane: " + className(m) + " " + struct(m)); |
42 | ret m; |
43 | } |
44 | |
45 | public synchronized Map getHashMap(S name) { |
46 | Map m = hashMaps.get(name); |
47 | if (m == null) { |
48 | hashMaps.put(name, m = mapInConcept(this, new HashMap)); |
49 | change(); |
50 | } |
51 | applyPersistentMapLogFile(_concepts.programID, name, m, !nonSaving); |
52 | if (getOpt_raw(m, 'm) == null) |
53 | fail("map not sane: " + className(m) + " " + struct(m)); |
54 | ret m; |
55 | } |
56 | |
57 | public synchronized Set getTreeSet(S name) { |
58 | Set m = treeSets.get(name); |
59 | if (m == null) { |
60 | treeSets.put(name, m = setInConcept(this, new TreeSet)); |
61 | change(); |
62 | } |
63 | ret m; |
64 | } |
65 | } |
Began life as a copy of #1009399
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, imzmzdywqqli, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1009401 |
Snippet name: | PersistentLister |
Eternal ID of this version: | #1009401/28 |
Text MD5: | e2b6c5366544438e02890d3fac3268d2 |
Author: | stefan |
Category: | javax / lists |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-09-28 10:00:49 |
Source code size: | 1780 bytes / 65 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 532 / 1771 |
Version history: | 27 change(s) |
Referenced in: | [show references] |