Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module threadsafe.map;
- synchronized class Map(TKey,TValue) {
- private:
- TValue[TKey] _map;
- public:
- void add(TKey key, TValue value) {
- _map[key] = value;
- }
- bool contains(TKey key) {
- return (key in _map) !is null;
- }
- @property int length() { return _map.length; }
- auto get(TKey key) {
- return _map.get(key, null);
- }
- void remove(TKey key) {
- if (contains(key)) {
- _map.remove(key);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement