Advertisement
Guest User

what?

a guest
Jul 2nd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.43 KB | None | 0 0
  1. module threadsafe.map;
  2.  
  3. synchronized class Map(TKey,TValue) {
  4.     private:
  5.     TValue[TKey] _map;
  6.    
  7.     public:
  8.     void add(TKey key, TValue value) {
  9.         _map[key] = value;
  10.     }
  11.    
  12.     bool contains(TKey key) {
  13.         return (key in _map) !is null;
  14.     }
  15.    
  16.     @property int length() { return _map.length; }
  17.    
  18.     auto get(TKey key) {
  19.         return _map.get(key, null);
  20.     }
  21.    
  22.     void remove(TKey key) {
  23.         if (contains(key)) {
  24.             _map.remove(key);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement