static class DerivedSet<A> extends AbstractSet<A> { Set<A> base; Set<A> additions = new HashSet; *() {} *(Set<A> *base) {} *(Set<A> *base, Set<A> *additions) {} public int size() { ret base.size()+additions.size(); } public Iterator<A> iterator() { fail(); } public bool contains(O o) { ret base.contains(o) || additions.contains(o); } public bool add(A a) { ret !base.contains(a) && additions.add(a); } // does not remove from base set, only from additions public bool remove(O o) { ret additions.remove(o); } O mutex() { ret collectionMutex(additions); } }
Began life as a copy of #1017455
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1018030 |
| Snippet name: | class DerivedSet - base set + additions |
| Eternal ID of this version: | #1018030/1 |
| Text MD5: | ffc89bfbc9eff27dd14960a78340e907 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-08-26 17:20:19 |
| Source code size: | 625 bytes / 21 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 615 / 1157 |
| Referenced in: | #1021317 - CombinedSet - only supports size() [estimated] and contains() #1022171 - LinkedTreeSet [TreeSet + order of insertion, not synchronized, optimized except for remove] #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |