Guest User

Untitled

a guest
Jun 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. Set<T> s = Collections.synchronizedSet(new LinkedHashSet<T>(...));
  2.  
  3. class DeleteOnReadMap<K, V> implements Map<K, V> {
  4.  
  5. private Map<K, V> m = new LinkedHashMap<K, V>();
  6.  
  7. // implement Map "read" methods Map with delete-on-read semantics
  8. public V get(K key) {
  9. // ...
  10. }
  11. // (other read methods here)
  12.  
  13. // implement remaining Map methods by forwarding to inner Map
  14. public V put(K key, V value) {
  15. return m.put(key, value);
  16. }
  17. // (remaining Map methods here)
  18. }
  19.  
  20. Map<K, V> m = Collections.synchronizedMap(new DeleteOnReadMap<K, V>(...));
  21.  
  22. Collections.synchronizedMap(new LinkedHashMap<K, V>());
Add Comment
Please, Sign In to add comment