Module: Weak::Map::AbstractStrongKeys Abstract
- Included in:
- StrongKeys, StrongSecondaryKeys
- Defined in:
- lib/weak/map/abstract_strong_keys.rb
Overview
This module implements a common subset of (helper-)methods
for a Weak::Map with an ObjectSpace::WeakMap
with strong keys, i.e.,
StrongKeys and StrongSecondaryKeys.
Instance Method Summary collapse
-
#keys ⇒ Array
An
Array
containing all keys of the map for which we have a valid value. -
#size ⇒ Integer
The number of live key-value pairs in
self
. -
#values ⇒ Array
An
Array
containing all values of the map for which we have a valid key.
Instance Method Details
#keys ⇒ Array
In contrast to a Hash
, Weak::Map
s do not necessarily retain
insertion order.
Returns an Array
containing all keys of the map for which we
have a valid value. Keys with garbage-collected values are excluded.
20 21 22 |
# File 'lib/weak/map/abstract_strong_keys.rb', line 20 def keys each_key.to_a end |
#size ⇒ Integer
Returns the number of live key-value pairs in self
.
25 26 27 |
# File 'lib/weak/map/abstract_strong_keys.rb', line 25 def size each_key.count end |
#values ⇒ Array
In contrast to a Hash
, Weak::Map
s do not necessarily retain
insertion order.
Returns an Array
containing all values of the map for which we
have a valid key. Values with garbage-collected keys are excluded.
30 31 32 |
# File 'lib/weak/map/abstract_strong_keys.rb', line 30 def values each_value.to_a end |