sclass MapInConcept<K, V> implements Map<K, V> { Map<K, V> m; // Backing Map Concept cc; *() {} // for persistence *(Map<K, V> *m, Concept *cc) {} public int size() { synchronized (this) {return m.size();} } public boolean isEmpty() { synchronized (this) {return m.isEmpty();} } public boolean containsKey(Object key) { synchronized (this) {return m.containsKey(key);} } public boolean containsValue(Object value) { synchronized (this) {return m.containsValue(value);} } public V get(Object key) { synchronized (this) {return m.get(key);} } public V put(K key, V value) { try { synchronized (this) {return m.put(key, value);} } finally { cc.change(); } } public V remove(Object key) { try { synchronized (this) {return m.remove(key);} } finally { cc.change(); } } public void putAll(Map<? extends K, ? extends V> map) { synchronized (this) {m.putAll(map);} cc.change(); } public void clear() { synchronized (this) {m.clear();} cc.change(); } private transient Set<K> keySet; private transient Set<Map.Entry<K,V>> entrySet; private transient Collection<V> values; public Set<K> keySet() { synchronized (this) { if (keySet==null) keySet = new SynchronizedSet(m.keySet(), this); return keySet; } } public Set<Map.Entry<K,V>> entrySet() { synchronized (this) { if (entrySet==null) entrySet = new SynchronizedSet(m.entrySet(), this); return entrySet; } } public Collection<V> values() { synchronized (this) { if (values==null) values = new SynchronizedCollection(m.values(), this); return values; } } public boolean equals(Object o) { if (this == o) return true; synchronized (this) {return m.equals(o);} // TODO: deadlock? } public int hashCode() { synchronized (this) {return m.hashCode();} } public String toString() { synchronized (this) {return m.toString();} } // 1.8 stuff omitted Map<K, V> unwrap() { ret m; } }
Began life as a copy of #1009405
download show line numbers debug dex old transpilations
Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, imzmzdywqqli, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, ppjhyzlbdabe, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1009413 |
Snippet name: | MapInConcept |
Eternal ID of this version: | #1009413/7 |
Text MD5: | 2081b6d9c2bf7d567e0457bc611b1265 |
Author: | stefan |
Category: | javax / concepts |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-08-07 18:34:04 |
Source code size: | 2210 bytes / 80 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 420 / 2444 |
Version history: | 6 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |