multiset 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDhmOWRlOWI0ZWUzY2NmZjc4NDQwOTE0MmFjYWVlNzFjOTVhNTJhMQ==
5
- data.tar.gz: !binary |-
6
- ZTg5YzE1NmQzYTYzM2I5ODAxMmIzMDdiMDI0ODI0YWJjMDhhYzMwZg==
2
+ SHA1:
3
+ metadata.gz: a7c8af89e0f0f6799fffe4ded50e5fd4c18ae970
4
+ data.tar.gz: 32333ad6798227b37eb6c9430a4ce57d21a5a95e
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MGRlZGU0MWNlNjljMDQ3ZGYwODVhMjdhN2Y5NzU3N2M2MTY4MTM5NTYxZjcw
10
- Y2ZlM2VjMzQ1MmRlMjRjNzNiNmUyNjBiMjgxM2Q4NGNiYzYwMzk3MGQ0ZDBi
11
- YzQxMjZkMWYxMGNmYzg5YmEyOWM1MGFlYTM0ZWJiOTY2NDk4ZDQ=
12
- data.tar.gz: !binary |-
13
- NThjZDRhZTlhOWRmYzU3ZGE0NjI4NzM4MGMwZjAyOThmZjFlMzQxNGQ5MDAz
14
- M2QyOGNlOTdkMzM2MGE0NGJhZWQwYjBmZDM2Y2UyMDg4MmI1ZmMxMDQ0Zjc2
15
- YzVmMjllYzg2MDJhMzhmMTAwMDBkOTY0MzJhNTI1ODE3MjJlOTc=
6
+ metadata.gz: 2872da1b9db75cc7a04980d1efa2b153d95d4d2713472285038a80ce6f7ace40a04d4e3fcb04ef68d9fb1ba4870e0bb15f3676d1b14d9084df023cb9401efda3
7
+ data.tar.gz: 650b478fb6144d634032f36e18ecf796f63b21cb23ca20c38e7213fdfbe36d0ae2082092d133cfa51d8464bc1b0ef9aef74923fded3c533e79c2f883a5e3838f
@@ -230,3 +230,13 @@
230
230
 
231
231
  (en)
232
232
  * Fixed argument descriptions of some methods in the RDoc document.
233
+
234
+ === 0.5.3 / 2017-04-28
235
+
236
+ (ja)
237
+ * ドキュメントを修正(特に英語の記述について)。
238
+ * Multimap#each_key が、ブロックを与えない場合にEnumeratorを返すようにした。
239
+
240
+ (en)
241
+ * Fixed documentation, especially in English writing.
242
+ * Multimap#each_key returns an Enumerator if no block is given.
data/README.txt CHANGED
@@ -19,6 +19,9 @@ Multisets are typically used for counting elements and their appearances in coll
19
19
 
20
20
  == SYNOPSIS:
21
21
 
22
+ The document for detailed APIs can be generated by rdoc. http://docs.ruby-lang.org/en/2.2.0/RDoc/Markup.html
23
+ Rdoc-generated document is available at: http://maraigue.hhiro.net/multiset/doc5/
24
+
22
25
  # Creating a multiset
23
26
  Set[:a,:b,:c,:b,:b,:c] # => #<Set: {:b, :c, :a}>
24
27
  Multiset[:a,:b,:c,:b,:b,:c] # => #<Multiset:#3 :b, #2 :c, #1 :a>
@@ -5,20 +5,18 @@ require "multiset"
5
5
 
6
6
  #==概要(Basic information)
7
7
  #
8
- #Rubyによる多重連想配列(マルチマップ)の実装です。
9
- #通常の連想配列(Rubyでは"Hash"クラス)と異なり、多重連想配列は
10
- #1つのキーに対して複数の要素が存在し得ます。
8
+ # Ruby implementation of multimap.
9
+ # Unlike ordinary map, also known as associative array
10
+ # (see Ruby documentation for "Hash" class),
11
+ # multimap can contain two or more items for a key.
11
12
  #
12
- #メソッド名は基本的にHashクラスに合わせてあります。またHashクラスが持つ
13
- #メソッドの大部分を実装していますが、いくつか未実装なものもあります。
13
+ # Methods' names are basically consistent with those of Hash class.
14
14
  #
15
- #Ruby implementation of multimap.
16
- #Unlike ordinary map, also known as associative array
17
- #(see Ruby documentation for "Hash" class),
18
- #multimap can contain two or more items for a key.
15
+ # Rubyによる多重連想配列(マルチマップ)の実装です。
16
+ # 通常の連想配列(Rubyでは"Hash"クラス)と異なり、多重連想配列は
17
+ # 1つのキーに対して複数の要素が存在し得ます。
19
18
  #
20
- #Most methods’ names are same as those of Hash class, and all other than
21
- #a few methods in Hash class is implemented on Multimap class.
19
+ # メソッド名は基本的にHashクラスに合わせてあります。
22
20
 
23
21
  class Multimap
24
22
  include Enumerable
@@ -27,11 +25,11 @@ class Multimap
27
25
  # Constructors
28
26
  #++
29
27
 
28
+ # Generates a new multimap. Different from Hash#new , you cannot
29
+ # specify default value.
30
+ #
30
31
  # 新しい多重連想配列を生成します。Hash#newと異なり、デフォルト値は
31
32
  # 設定できません。
32
- #
33
- # Generates a new multimap. Different from Hash#new , you can not
34
- # specify default value.
35
33
  def initialize
36
34
  @assoc = Hash.new{ |hash, key| hash[key] = Multiset.new }
37
35
  end
@@ -43,31 +41,34 @@ class Multimap
43
41
  end
44
42
  private :cleanup
45
43
 
46
- # キー<code>key</code>に対応する値(複数存在しうる)を、
47
- # Multisetとして返します。Hash#fetchの場合と異なり、キーに対応する
48
- # 値が存在しない場合の扱いを指定することはできません。
49
- # (そのような場合、空のMultisetが返ります。)
50
- #
51
- # Returns values associated with <code>key</code> with format of
52
- # Multiset. Different from Hash#fetch, you can not specify
53
- # a value or a process when <code>key</code> has not associated with
54
- # any value. If <code>key</code> has not associated with any value,
44
+ # Returns values associated with <code>key</code>, which may exist
45
+ # two or more, by the format of Multiset.
46
+ # If <code>key</code> has not associated with any value,
55
47
  # Multimap#fetch returns empty Multiset.
48
+ # Different from Hash#fetch, you cannot specify
49
+ # a value or a process when <code>key</code> has not associated with
50
+ # any value.
51
+ #
52
+ # キー<code>key</code>に対応する値(複数存在しうる)を、
53
+ # Multisetとして返します。
54
+ # キーに対応する値が存在しない場合、空のMultisetが返ります。
55
+ # Hash#fetchの場合と異なり、キーに対応する値が存在しない場合の扱いを
56
+ # 指定することはできません。
56
57
  def fetch(key)
57
58
  @assoc[key]
58
59
  end
59
60
  alias :[] :fetch
60
61
 
62
+ # Sets values associated with <code>key</code> to <code>value_list</code>.
63
+ # <code>value_list</code> is converted to a Multiset by Multiset.parse .
64
+ #
65
+ # Returns <code>value_list</code>.
66
+ #
61
67
  # キー<code>key</code>に対応する値(複数存在しうる)を
62
68
  # <code>value_list</code>で置き換えます。この際、
63
69
  # <code>value_list</code>はMultiset.parseを用いてMultisetに変換されます。
64
70
  #
65
71
  # <code>value_list</code>を返します。
66
- #
67
- # Sets values associated with <code>key</code> to <code>value_list</code>.
68
- # <code>value_list</code> is converted to a Multiset by Multiset.parse .
69
- #
70
- # Returns <code>value_list</code>.
71
72
  def store(key, value_list)
72
73
  if value_list.class == Multiset
73
74
  @assoc[key] = value_list.dup
@@ -78,46 +79,44 @@ class Multimap
78
79
  end
79
80
  alias :[]= :store
80
81
 
81
- # <code>self</code>が<code>other</code>と等しいかどうかを返します。
82
- #
83
82
  # Returns whether <code>self</code> is equal to <code>other</code>.
83
+ #
84
+ # <code>self</code>が<code>other</code>と等しいかどうかを返します。
84
85
  def ==(other)
85
86
  return false unless other.instance_of?(Multimap)
86
87
  @assoc == other.to_hash
87
88
  end
88
89
 
89
- # <code>self</code>を<code>Hash</code>に変換して返します。
90
- # 生成されるハッシュの構造については、Hash#to_multimapをご覧下さい。
91
- # その際、返されるハッシュにおいて値はすべてMultimap型となります。
90
+ # Converts <code>self</code> to a <code>Hash</code>
91
+ # whose values in the Hash are all multimaps.
92
92
  #
93
- # Converts <code>self</code> to a <code>Hash</code>.
94
- # See Hash#to_multimap about format of generated hash.
95
- # All values in the returned hash are multimaps.
93
+ # <code>self</code>を<code>Hash</code>に変換して返します。
94
+ # 返されるHash中において、値はすべてMultimap型となります。
96
95
  def to_hash
97
96
  @assoc.dup
98
97
  end
99
98
 
100
- # <code>self</code>に格納された要素をすべて削除します。
101
- # <code>self</code>を返します。
102
- #
103
99
  # Removes all elements stored in <code>self</code>.
104
100
  # Returns <code>self</code>.
101
+ #
102
+ # <code>self</code>に格納された要素をすべて削除します。
103
+ # <code>self</code>を返します。
105
104
  def clear
106
105
  @assoc.clear
107
106
  end
108
107
 
109
- # <code>self</code>の複製を生成して返します。
110
- #
111
108
  # Returns duplicated <code>self</code>.
109
+ #
110
+ # <code>self</code>の複製を生成して返します。
112
111
  def dup
113
112
  @assoc.to_multimap
114
113
  end
115
114
 
116
- # <code>self</code>の内容を<code>other</code>のものに置き換えます。
117
- # <code>self</code>を返します。
118
- #
119
115
  # Replaces <code>self</code> by <code>other</code>.
120
116
  # Returns <code>self</code>.
117
+ #
118
+ # <code>self</code>の内容を<code>other</code>のものに置き換えます。
119
+ # <code>self</code>を返します。
121
120
  def replace(other)
122
121
  @assoc.clear
123
122
  other.each_pair_with do |key, a_value, count|
@@ -126,37 +125,37 @@ class Multimap
126
125
  self
127
126
  end
128
127
 
129
- # <code>key</code>に割り当てられた全ての値を削除し、その値を
130
- # Multisetとして返します。
131
- #
132
128
  # Deletes all values associated with <code>key</code>, and returns
133
129
  # those values as a Multiset.
130
+ #
131
+ # <code>key</code>に割り当てられた全ての値を削除し、その値を
132
+ # Multisetとして返します。
134
133
  def delete(key)
135
134
  ret = @assoc[key]
136
135
  @assoc.delete(key)
137
136
  ret
138
137
  end
139
138
 
140
- # delete_ifと同じですが、<code>self</code>自身からはキーと値の組を
139
+ # Same as Multimap#delete_if except that, rather than deleting key-value pairs in
140
+ # <code>self</code>, this generates a new Multimap with specified
141
+ # key-value pairs are deleted.
142
+ #
143
+ # Multimap#delete_ifと似ますが、<code>self</code>自身からはキーと値の組を
141
144
  # 削除せず、要素が削除された結果の多重連想配列を新たに生成して
142
145
  # 返します。
143
- #
144
- # Same as delete_if, but generates a new Multimap whose pairs of
145
- # key and value are deleted, instead of deleting pairs in
146
- # <code>self</code>.
147
146
  def reject(&block) # :yields: key, single_value
148
147
  ret = self.dup
149
148
  ret.delete_if &block
150
149
  ret
151
150
  end
152
151
 
153
- # ブロックに<code>self</code>のキーと値の組(値は1つ)を順次与え、
154
- # 結果が真であった組をすべて削除します。
155
- # <code>self</code>を返します。
156
- #
157
152
  # Gives all pairs of a key and single value in <code>self</code>
158
153
  # to given block, and deletes that element if the block returns true.
159
154
  # Returns <code>self</code>.
155
+ #
156
+ # ブロックに<code>self</code>のキーと値の組(値は1つ)を順次与え、
157
+ # 結果が真であった組をすべて削除します。
158
+ # <code>self</code>を返します。
160
159
  def delete_if(&block) # :yields: key, single_value
161
160
  cleanup
162
161
  @assoc.each_pair do |key, value_list|
@@ -167,11 +166,11 @@ class Multimap
167
166
  self
168
167
  end
169
168
 
170
- # delete_ifと同じですが、キーと値の組が1つも削除されなければ
171
- # <code>nil</code>を返します。
169
+ # Same as Multimap#delete_if except that <code>nil</code> is returned
170
+ # if no key-value pair is deleted.
172
171
  #
173
- # Same as delete_if, but returns <code>nil</code> if no pair of
174
- # key and value is deleted.
172
+ # Multimap#delete_ifと似ますが、キーと値の組が1つも削除されなければ
173
+ # <code>nil</code>を返します。
175
174
  def reject!(&block) # :yields: key, single_value
176
175
  cleanup
177
176
  ret = nil
@@ -183,24 +182,24 @@ class Multimap
183
182
  ret
184
183
  end
185
184
 
186
- # rejectと同じですが、ブロックへの引数が(キー、キーに割り当てられた値、
187
- # その値がキーに割り当てられている個数)の3つの組で与えられます。
188
- #
189
- # Same as reject, but arguments given to block is the tuple of three:
190
- # (key, one value associated with the key, numbers of that value
185
+ # Same as Multimap#reject except that arguments given to block is the following three:
186
+ # (key, single value associated with the key, numbers of that value
191
187
  # associated with the key).
188
+ #
189
+ # Multimap#rejectと似ますが、ブロックへの引数が(キー、キーに割り当てられた値、
190
+ # その値がキーに割り当てられている個数)の3つの組で与えられます。
192
191
  def reject_with(&block) # :yields: key, a_value, count
193
192
  ret = self.dup
194
193
  ret.delete_with &block
195
194
  ret
196
195
  end
197
196
 
198
- # delete_ifと同じですが、ブロックへの引数が(キー、キーに割り当てられた値、
199
- # その値がキーに割り当てられている個数)の3つの組で与えられます。
200
- #
201
- # Same as delete_if, but arguments given to block is the tuple of three:
202
- # (key, one value associated with the key, numbers of that value
197
+ # Same as Multimap#delete_if except that arguments given to block is the following three:
198
+ # (key, single value associated with the key, numbers of that value
203
199
  # associated with the key).
200
+ #
201
+ # Multimap#delete_ifと同じですが、ブロックへの引数が(キー、キーに割り当てられた値、
202
+ # その値がキーに割り当てられている個数)の3つの組で与えられます。
204
203
  def delete_with(&block) # :yields: key, a_value, count
205
204
  cleanup
206
205
  @assoc.each_pair do |key, value_list|
@@ -211,11 +210,11 @@ class Multimap
211
210
  self
212
211
  end
213
212
 
214
- # <code>self</code>のすべてのキーと値の組について繰り返します。
215
- # <code>self</code>を返します。
216
- #
217
213
  # Iterates for each pair of a key and a value in <code>self</code>.
218
214
  # Returns <code>self</code>.
215
+ #
216
+ # <code>self</code>のすべてのキーと値の組について繰り返します。
217
+ # <code>self</code>を返します。
219
218
  def each_pair
220
219
  if block_given?
221
220
  cleanup
@@ -231,14 +230,14 @@ class Multimap
231
230
  end
232
231
  alias :each :each_pair
233
232
 
233
+ # Iterates for each pair of a key and a value in <code>self</code>,
234
+ # giving the following three to block:
235
+ # (key, single value associated with the key, numbers of that value
236
+ # associated with the key). Returns <code>self</code>.
237
+ #
234
238
  # <code>self</code>のすべてのキーと値の組について、
235
239
  # ブロックに(キー、キーに割り当てられた値、その値が割り当てられた数)
236
240
  # の組を与えながら繰り返します。<code>self</code>を返します。
237
- #
238
- # Iterates for each pair of a key and a value in <code>self</code>,
239
- # giving the tuple of three to block:
240
- # (key, one value associated with the key, numbers of that value
241
- # associated with the key). Returns <code>self</code>.
242
241
  def each_pair_with
243
242
  if block_given?
244
243
  cleanup
@@ -253,32 +252,36 @@ class Multimap
253
252
  end
254
253
  end
255
254
 
256
- # <code>self</code>のすべてのキーと、そのキーに割り当てられた
257
- # すべての値(Multisetで与えられる)の組について繰り返します。
258
- # <code>self</code>を返します。
259
- #
260
255
  # Iterates for each pair of a key and all values associated with the key
261
256
  # (list of values is given as Multiset) in <code>self</code>.
262
257
  # Returns <code>self</code>.
258
+ #
259
+ # <code>self</code>のすべてのキーと、そのキーに割り当てられた
260
+ # すべての値(Multisetで与えられる)の組について繰り返します。
261
+ # <code>self</code>を返します。
263
262
  def each_pair_list(&block) # :yields: key, value_list
264
263
  cleanup
265
264
  @assoc.each_pair &block
266
265
  end
267
266
 
268
267
 
268
+ # Iterates for each key in <code>self</code>. Returns <code>self</code>.
269
+ #
269
270
  # <code>self</code>のすべてのキーについて繰り返します。
270
271
  # <code>self</code>を返します。
271
- #
272
- # Iterates for each key in <code>self</code>. Returns <code>self</code>.
273
272
  def each_key(&block) # :yields: key
274
- cleanup
275
- @assoc.each_key &block
273
+ if block_given?
274
+ cleanup
275
+ @assoc.each_key &block
276
+ else
277
+ Enumerator.new(self, :each_key)
278
+ end
276
279
  end
277
280
 
281
+ # Iterates for each value in <code>self</code>. Returns <code>self</code>.
282
+ #
278
283
  # <code>self</code>のすべての値について繰り返します。
279
284
  # <code>self</code>を返します。
280
- #
281
- # Iterates for each value in <code>self</code>. Returns <code>self</code>.
282
285
  def each_value(&block) # :yields: single_value
283
286
  if block_given?
284
287
  cleanup
@@ -291,18 +294,18 @@ class Multimap
291
294
  end
292
295
  end
293
296
 
294
- # <code>self</code>のすべてのキーを、配列として返します。
295
- #
296
297
  # Returns an array in which keys in <code>self</code> are stored.
298
+ #
299
+ # <code>self</code>のすべてのキーを、配列として返します。
297
300
  def keys
298
301
  cleanup
299
302
  @assoc.keys
300
303
  end
301
304
 
302
305
 
303
- # <code>self</code>のすべての値を、Multisetとして返します。
304
- #
305
306
  # Returns a Multiset in which values in <code>self</code> are stored.
307
+ #
308
+ # <code>self</code>のすべての値を、Multisetとして返します。
306
309
  def values
307
310
  cleanup
308
311
  ret = Multiset.new
@@ -312,17 +315,17 @@ class Multimap
312
315
  ret
313
316
  end
314
317
 
315
- # <code>self</code>に要素がないかどうかを返します。
316
- #
317
318
  # Returns whether <code>self</code> has no element.
319
+ #
320
+ # <code>self</code>に要素がないかどうかを返します。
318
321
  def empty?
319
322
  cleanup
320
323
  @assoc.empty?
321
324
  end
322
325
 
323
- # <code>self</code>にキー<code>key</code>かあるかどうかを返します。
324
- #
325
326
  # Returns whether <code>self</code> has a key <code>key</code>.
327
+ #
328
+ # <code>self</code>にキー<code>key</code>かあるかどうかを返します。
326
329
  def has_key?(key)
327
330
  cleanup
328
331
  @assoc.has_key?(key)
@@ -331,23 +334,23 @@ class Multimap
331
334
  alias :include? :has_key?
332
335
  alias :member? :has_key?
333
336
 
334
- # <code>self</code>に値<code>value</code>かあるかどうかを返します。
335
- #
336
337
  # Returns whether <code>self</code> has a value <code>value</code>.
338
+ #
339
+ # <code>self</code>に値<code>value</code>かあるかどうかを返します。
337
340
  def has_value?(value)
338
341
  self.values.items.include?(value)
339
342
  end
340
343
  alias :value? :has_value?
341
344
 
342
- # <code>self</code>から値が<code>value</code>であるような要素を
343
- # 検索し、それに対応するキーを返します。該当するキーが複数存在する場合、
344
- # そのうちの1つを返します。該当するキーが存在しなければ
345
- # <code>nil</code>を返します。
346
- #
347
345
  # Search a pair of key and value from <code>self</code> such that
348
346
  # the value is equal to the argument <code>value</code>.
349
347
  # If two or keys are matched, returns one of them.
350
348
  # If no key is matched, returns nil.
349
+ #
350
+ # <code>self</code>から値が<code>value</code>であるような要素を
351
+ # 検索し、それに対応するキーを返します。該当するキーが複数存在する場合、
352
+ # そのうちの1つを返します。該当するキーが存在しなければ
353
+ # <code>nil</code>を返します。
351
354
  def key(value)
352
355
  self.each_pair_with do |key, a_value, count|
353
356
  return key if value == a_value
@@ -356,28 +359,28 @@ class Multimap
356
359
  end
357
360
  alias :index :key
358
361
 
362
+ # Retrieves values (instances of Multiset) of <code>self</code>
363
+ # associated with <code>key_list</code>, and returns those values
364
+ # as an array. i.e. returns an array whose elements are multisets.
365
+ #
359
366
  # <code>self</code>から<code>key_list</code>の各キーに対応する値
360
367
  # (Multiset型)を取り出し、それらを配列として返します。
361
368
  # すなわち、Multisetを要素とする配列を返します。
362
- #
363
- # Gets values (instances of Multiset) of <code>self</code>
364
- # associated with <code>key_list</code>, and returns those values
365
- # as an array. i.e. returns an array whose elements are multisets.
366
369
  def values_at(*key_list)
367
370
  key_list.map{ |key| self[key] }
368
371
  end
369
372
  alias :indexes :values_at
370
373
  alias :indices :values_at
371
374
 
372
- # <code>self</code>のキーと値を入れ替えたMultimapを返します。
373
- # 例えばキー:aに対応する値が2つの:xと1つの:yであれば、変換結果は
374
- # キー:xに:aが2つ、キー:yに:aが1つ対応するMultimapです。
375
- #
376
375
  # Returns a Multimap whose keys are values in <code>self</code>, and
377
376
  # values are keys in <code>self</code>. For example,
378
377
  # If <code>self</code> has a key :a associated with two :x and one :y,
379
378
  # returned multimap has two keys :x and :y, and their values are
380
379
  # two :a and one :a respectively.
380
+ #
381
+ # <code>self</code>のキーと値を入れ替えたMultimapを返します。
382
+ # 例えばキー:aに対応する値が2つの:xと1つの:yであれば、変換結果は
383
+ # キー:xに:aが2つ、キー:yに:aが1つ対応するMultimapです。
381
384
  def invert
382
385
  ret = Multimap.new
383
386
  self.each_pair_with do |key, a_value, count|
@@ -386,9 +389,9 @@ class Multimap
386
389
  ret
387
390
  end
388
391
 
389
- # <code>self</code>に含まれている要素数を返します。
390
- #
391
392
  # Returns number of all elements in <code>self</code>.
393
+ #
394
+ # <code>self</code>に含まれている要素数を返します。
392
395
  def size
393
396
  ret = 0
394
397
  self.each_pair_with{ |key, a_value, count| ret += count }
@@ -396,11 +399,11 @@ class Multimap
396
399
  end
397
400
  alias :length :size
398
401
 
399
- # <code>self</code>に<code>other</code>の要素を追加します。
400
- # <code>self</code>を返します。
401
- #
402
402
  # Add elements in <code>other</code> to <code>self</code>.
403
403
  # Returns <code>self</code>.
404
+ #
405
+ # <code>self</code>に<code>other</code>の要素を追加します。
406
+ # <code>self</code>を返します。
404
407
  def merge!(other)
405
408
  other.each_pair_with do |key, a_value, count|
406
409
  self[key].add a_value, count
@@ -408,9 +411,9 @@ class Multimap
408
411
  self
409
412
  end
410
413
 
411
- # <code>self</code>と<code>other</code>の要素を合わせた多重集合を返します。
412
- #
413
414
  # Returns merged multiset of <code>self</code> and <code>other</code>.
415
+ #
416
+ # <code>self</code>と<code>other</code>の要素を合わせた多重集合を返します。
414
417
  def merge(other)
415
418
  ret = self.dup
416
419
  ret.merge! other
@@ -453,16 +456,6 @@ class Multimap
453
456
  end
454
457
 
455
458
  class Hash
456
- # <code>self</code>を多重連想配列に変換し、その結果を返します。
457
- # 新しく生成される多重連想配列においてキーに割り当てられる値は、
458
- # <code>self</code>におけるキーの値をMultiset.parseによって多重集合に
459
- # 変換したものとなります。
460
- #
461
- # (例)キー<code>:a</code>には<code>:x</code>と<code>:y</code>が1個ずつ、
462
- # キー<code>:b</code>には<code>:x</code>が2個割り当てられた多重連想配列
463
- #
464
- # <code>{:a => [:x, :y], :b => [:x, :x]}.to_multimap</code>
465
- #
466
459
  # Generates multiset from <code>self</code>.
467
460
  # In generated multiset, values associated with a key are defined by
468
461
  # the result of Multiset.parse(values_in_<code>self</code>) .
@@ -472,19 +465,29 @@ class Hash
472
465
  # key <code>:b</code> is associated with values two <code>:x</code>
473
466
  #
474
467
  # <code>{:a => [:x, :y], :b => [:x, :x]}.to_multimap</code>
468
+ #
469
+ # <code>self</code>を多重連想配列に変換し、その結果を返します。
470
+ # 新しく生成される多重連想配列においてキーに割り当てられる値は、
471
+ # <code>self</code>におけるキーの値をMultiset.parseによって多重集合に
472
+ # 変換したものとなります。
473
+ #
474
+ # (例)キー<code>:a</code>には<code>:x</code>と<code>:y</code>が1個ずつ、
475
+ # キー<code>:b</code>には<code>:x</code>が2個割り当てられた多重連想配列
476
+ #
477
+ # <code>{:a => [:x, :y], :b => [:x, :x]}.to_multimap</code>
475
478
  def to_multimap
476
479
  ret = Multimap.new
477
480
  self.each_pair{ |key, val| ret[key] = val }
478
481
  ret
479
482
  end
480
483
 
481
- # <code>self</code>を多重連想配列に変換し、その結果を返します。
482
- # 新しく生成される多重連想配列においてキーに割り当てられる値は、
483
- # <code>self</code>に含まれる1要素のみです。
484
- #
485
484
  # Generates multiset from <code>self</code>.
486
485
  # In generated multiset, only one value is associated with a key
487
486
  # (value in <code>self</code>).
487
+ #
488
+ # <code>self</code>を多重連想配列に変換し、その結果を返します。
489
+ # 新しく生成される多重連想配列においてキーに割り当てられる値は、
490
+ # <code>self</code>に含まれる1要素のみです。
488
491
  def multimap
489
492
  ret = Multimap.new
490
493
  self.each_pair{ |key, val| ret[key] = Multiset[val] }