Class: Quickdraw::Map
- Inherits:
-
Object
- Object
- Quickdraw::Map
- Includes:
- Enumerable
- Defined in:
- lib/quickdraw/map.rb
Instance Method Summary collapse
- #[](value) ⇒ Object
- #[]=(key, value) ⇒ Object
- #clear ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ Map
constructor
A new instance of Map.
Constructor Details
#initialize ⇒ Map
Returns a new instance of Map.
6 7 8 9 |
# File 'lib/quickdraw/map.rb', line 6 def initialize @hash = {} @mutex = Mutex.new end |
Instance Method Details
#[](value) ⇒ Object
11 12 13 |
# File 'lib/quickdraw/map.rb', line 11 def [](value) @hash[value] end |
#[]=(key, value) ⇒ Object
15 16 17 18 19 |
# File 'lib/quickdraw/map.rb', line 15 def []=(key, value) @mutex.synchronize do @hash[key] = value end end |
#clear ⇒ Object
25 26 27 28 29 |
# File 'lib/quickdraw/map.rb', line 25 def clear @mutex.synchronize do @hash.clear end end |
#each ⇒ Object
21 22 23 |
# File 'lib/quickdraw/map.rb', line 21 def each(&) @hash.each(&) end |