multiset 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDBiNjk1YzU0M2U4ZTEzYzdlZjQwZTdhOWY3OGQ5MWI5MzJiNGY1OA==
4
+ OTM5ZWVlZGI1NzVhMmM4NDk2ZTRhNGJmOTg4YTVmNmY4M2NiZTExOA==
5
5
  data.tar.gz: !binary |-
6
- MDMwNjFmMTkzZjhmYjY0OTE3MzJjZDE2YTliZGE4NTdkZjVkMjM4MQ==
7
- !binary "U0hBNTEy":
6
+ NmRmNGI0ZjEyYzYxNjQ1NzIzOTRhMWI1ZmE3ODdmMjAxNjA2OTkwNg==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- YjdlOWFjMDBhY2E5YzllYzgzNjNmNjM0YWVjOTcyNGYyOWU2ZmZhNmFkYjdh
10
- MDkyYmIzMzg5NzVjNGRlODU1OGE5ZGUzZDhkOTUzNWY0ZGJmMjY4ZjI1Njcz
11
- NDNkOGU0OTEwZTYwNGE3ZjhlNmNjZTFjMzZiNTJiNDQ2MzdjODc=
9
+ NDlmYzA4M2RkNjNhZWExZDAwYzUwZjkyMGY5MWNjMzVlNzcwNjk2NGRhYTY0
10
+ NTQ3Mjg4YzhhOTIxNTJmNDdiYTAwZmRmMzM2OTA2YjU2ZDcwNGYxNDkwYzA3
11
+ YmUwNzZhMzFkMWM2ZTc0NWVjM2Q3MmM1YWExNTg2MGU1MGMzN2M=
12
12
  data.tar.gz: !binary |-
13
- NWRkNDVmMDg4Y2Q3ODMyMzkxMjliNGIwM2ZhNDBiNTdlZDVkMTc4M2U1MjMy
14
- ZDJmZTlmODRjOTNhMjMzOTlmY2MxOTc2MjNlMDg0MzBjOGMyZWQ3YmM1NTBh
15
- ZGU2OTUwOWU5ODMzYTZhOTFmNTQ0ZjIxZThkNzYwZjQ2ZTIwYzQ=
13
+ MmI2NmIyZWZjZmE2NDJhMWMwOWRkNzQzM2RjZDgxY2M3YzRmZGQ3MjZiZWIx
14
+ YTE4NzVlMmQ1N2FlNjJjYjlhNDFhODgzMDJkMGUxMWQxMjY1MGVhNTdmODM0
15
+ M2QwNmM2YTgwMThiZjllZmQ1NTdkYzExN2Y5NmY1NzYzZDRhM2Q=
@@ -214,3 +214,12 @@
214
214
  (en)
215
215
  * Multiset#each_**** and Multimap#each_**** returns an Enumerator if called without a block.
216
216
  (Forgot implementation although documented...)
217
+
218
+ === 0.5.0 / 2014-05-16
219
+
220
+ (ja)
221
+ * 空のmultisetに対して Multiset#sample を呼び出した場合、nilを返すようにした。(Array#sampleと挙動を合わせました)
222
+
223
+ (en)
224
+ * Multiset#sample returns nil in case the multiset is empty. (The same behavior as Array#sample.)
225
+
data/README.txt CHANGED
@@ -62,7 +62,7 @@ and generate the RDoc.
62
62
 
63
63
  (The MIT License)
64
64
 
65
- Copyright (c) 2008-2012 H.Hiro (Maraigue)
65
+ Copyright (c) 2008-2014 H.Hiro (Maraigue)
66
66
 
67
67
  Permission is hereby granted, free of charge, to any person obtaining
68
68
  a copy of this software and associated documentation files (the
@@ -3,7 +3,7 @@
3
3
 
4
4
  require "enumerator"
5
5
  require "multimap"
6
- VERSION = "0.4.1"
6
+ VERSION = "0.5.0"
7
7
 
8
8
  #==概要(Basic information)
9
9
  #
@@ -686,10 +686,13 @@ class Multiset
686
686
 
687
687
  # <code>self</code>の要素を無作為に1つ選んで返します。
688
688
  # すべての要素は等確率で選ばれます。
689
+ # 空のmultisetに対して呼び出した場合は<code>nil</code>を返します。
689
690
  #
690
691
  # Returns one item in <code>self</code> randomly.
691
692
  # All items are selected with the same probability.
693
+ # Returns <code>nil</code> in case the multiset is empty.
692
694
  def sample
695
+ return nil if empty?
693
696
  pos = Kernel.rand(self.size)
694
697
  @entries.each_pair do |item, count|
695
698
  pos -= count
@@ -230,7 +230,11 @@ describe Multiset do
230
230
  it "should return a new Multiset by the specified condition with Multiset#map_with / Multiset#collect_with" do
231
231
  @ms.map_with{ |item, count| [item * 2, count * 2] }.should == Multiset.new(%w'aa aa aa aa bb bb bb bb bb bb bb bb cc cc dd dd dd dd dd dd')
232
232
  end
233
-
233
+
234
+ it "should return nil for an empty Multiset with Multiset#rand" do
235
+ Multiset.new.rand.should == nil
236
+ end
237
+
234
238
  it "should return the maximum/mininum value by max/min/minmax" do
235
239
  @ms.max.should == "d"
236
240
  @ms.min.should == "a"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiset
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - H.Hiro(Maraigue)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-01 00:00:00.000000000 Z
11
+ date: 2014-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubyforge_project: multiset
83
- rubygems_version: 2.0.3
83
+ rubygems_version: 2.1.11
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: Unlike ordinary set(see Ruby documentation for "set" library), multiset can