This repository was archived by the owner on Mar 15, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ def [](key)
3232 @values [ rkey ] if rkey
3333 end
3434
35+ alias_method :get , :[]
36+
3537 # Add a key/value to the map.
3638 def []=( key , value )
3739 ObjectSpace . define_finalizer ( key , @reference_cleanup )
@@ -41,6 +43,8 @@ def []=(key, value)
4143 end
4244 end
4345
46+ alias_method :put , :[]=
47+
4448 # Remove the value associated with the key from the map.
4549 def delete ( key )
4650 rkey = ref_key ( key )
@@ -90,7 +94,7 @@ def merge!(other_hash)
9094
9195 # The number of entries in the map
9296 def size
93- @references_to_keys_map . count do |rkey , ref |
97+ @references_to_keys_map . count do |_ , ref |
9498 ref . object
9599 end
96100 end
@@ -99,7 +103,11 @@ def size
99103
100104 # True if there are entries that exist in the map
101105 def empty?
102- size == 0
106+ @references_to_keys_map . each do |_ , ref |
107+ return false if ref . object
108+ end
109+
110+ true
103111 end
104112
105113 def inspect
Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ def [](key)
3333 value
3434 end
3535
36+ alias_method :get , :[]
37+
3638 # Add a key/value to the map.
3739 def []=( key , value )
3840 ObjectSpace . define_finalizer ( value , @reference_cleanup )
@@ -49,6 +51,8 @@ def []=(key, value)
4951 value
5052 end
5153
54+ alias_method :put , :[]=
55+
5256 # Remove the entry associated with the key from the map.
5357 def delete ( key )
5458 ref = @references . delete ( key )
@@ -104,7 +108,7 @@ def merge!(other_hash)
104108
105109 # The number of entries in the map
106110 def size
107- @references . count do |key , ref |
111+ @references . count do |_ , ref |
108112 ref . object
109113 end
110114 end
@@ -113,7 +117,11 @@ def size
113117
114118 # True if there are entries that exist in the map
115119 def empty?
116- size == 0
120+ @references . each do |_ , ref |
121+ return false if ref . object
122+ end
123+
124+ true
117125 end
118126
119127 def inspect
You can’t perform that action at this time.
0 commit comments