Libraryless. Click here for Pure Java version (4091L/26K).
sclass SimpleFactStore implements IFactStore { L<Fact> facts = synchroList(); transient bool verbose; transient L<Runnable> onChange = syncList(); sclass Fact extends HasGlobalID { long created = now(); S text; *() {} *(S *text) {} toString { ret text; } } public void store(S fact) { if (!any(facts, f -> eqic(f.text, fact))) { facts.add(new Fact(fact)); pcallFAll(onChange); } } public void deleteAll(IPred<S> filter) { for (Fact f : cloneList(facts)) if (filter.get(f.text)) { if (verbose) print("Deleting fact: " + f); facts.remove(f); pcallFAll(onChange); } } public LS facts() { ret map(facts, f -> f.text); } toString { ret sfu(this); } void onChange(Runnable r) { onChange.add(r); } void clear { facts.clear(); pcallFAll(onChange); } }
Began life as a copy of #1025750
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1025752 |
| Snippet name: | SimpleFactStore |
| Eternal ID of this version: | #1025752/9 |
| Text MD5: | ae98268a85fb2c5eb64a19fe2ad9b030 |
| Transpilation MD5: | 51dcb4c293d13e872632f28ed569674f |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-10-17 23:48:59 |
| Source code size: | 937 bytes / 42 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 455 / 918 |
| Version history: | 8 change(s) |
| Referenced in: | [show references] |