static <A> Set<A> setWithNotifyOnAdd(final VF1<A> onAdd) { ret setWithNotifyOnAdd(onAdd, new HashSet); } static <A> Set<A> setWithNotifyOnAdd(final VF1<A> onAdd, Set<A> set) { ret new NotifyingSet<A>(set) { void change() {} public bool add(A a) { if (!super.add(a)) false; ret true with callF(onAdd, a); } public bool addAll(Collection<? extends A> l) { bool change = false; for (A a : l) if (add(a)) change = true; ret change; } }; }
Began life as a copy of #1020632
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1021582 |
Snippet name: | setWithNotifyOnAdd - returns synchronized set that calls callback on successful add() (where element wasn't there before) |
Eternal ID of this version: | #1021582/7 |
Text MD5: | aef1e8332b91015e13250647724e6ab4 |
Author: | stefan |
Category: | javax / collections |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-02-19 11:44:30 |
Source code size: | 520 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 326 / 331 |
Version history: | 6 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |