class Hash
Public Instance Methods
Generates multiset from self
. In generated multiset, only one value is associated with a key (value in self
).
self
を多重連想配列に変換し、その結果を返します。 新しく生成される多重連想配列においてキーに割り当てられる値は、 self
に含まれる1要素のみです。
# File lib/multimap.rb, line 491 def multimap ret = Multimap.new self.each_pair{ |key, val| ret[key] = Multiset[val] } ret end
Generates multiset from self
. In generated multiset, values associated with a key are defined by the result of Multiset.parse
(values_in_self
) .
(example) Key :a
is associated with values one :x
and one :y
, and key :b
is associated with values two :x
{:a => [:x, :y], :b => [:x, :x]}.to_multimap
self
を多重連想配列に変換し、その結果を返します。 新しく生成される多重連想配列においてキーに割り当てられる値は、 self
におけるキーの値をMultiset.parseによって多重集合に 変換したものとなります。
(例)キー:a
には:x
と:y
が1個ずつ、 キー:b
には:x
が2個割り当てられた多重連想配列
{:a => [:x, :y], :b => [:x, :x]}.to_multimap
# File lib/multimap.rb, line 478 def to_multimap ret = Multimap.new self.each_pair{ |key, val| ret[key] = val } ret end
Generates multiset from self
. Keys of the Hash
are treated as items in the multiset, while values of the Hash
are number of items.
(example) {:a => 4, :b => 2}.to_multiset # Multiset with four :a's and two :b's
self
を多重集合に変換し、その結果を返します。 Hashのキーを要素、Hashの値をその要素の要素数とします。
(例){:a => 4, :b => 2}.to_multiset # :aを4個、:bを2個含む多重集合
# File lib/multiset.rb, line 1182 def to_multiset ret = Multiset.new self.each_pair{ |item, count| ret.renew_count(item, count) } ret end