Class | NestedMultimap |
In: |
lib/rack/mount/vendor/multimap/nested_multimap.rb
|
Parent: | Multimap |
NestedMultimap allows values to be assoicated with a nested set of keys.
Pushes the given object on to the end of all the containers.
map = NestedMultimap["a" => [100], "b" => [200, 300]] map << 300 map["a"] #=> [100, 300] map["c"] #=> [300]
Returns a new array populated with all the containers from map including the default.
map = NestedMultimap.new map["a"] = 100 map["a", "b"] = 101 map["a"] = 102 map.containers_with_default #=> [[100, 101, 102], [100, 102], []]
Calls block once for each key/container in map, passing the key and container to the block as parameters.
map = NestedMultimap.new map["a"] = 100 map["a", "b"] = 101 map["a"] = 102 map["c"] = 200 map.each_association { |key, container| puts "#{key} is #{container}" }
produces:
["a", "b"] is [100, 101, 102] "c" is [200]
Calls block for every container in map including the default, passing the container as a parameter.
map = NestedMultimap.new map["a"] = 100 map["a", "b"] = 101 map["a"] = 102 map.each_container_with_default { |container| puts container }
produces:
[100, 101, 102] [100, 102] []