rb_lovely 0.7.2 → 0.7.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 +4 -4
- data/ext/rb_lovely/sorted_hash.cpp +1 -0
- data/ext/rb_lovely/sorted_set.cpp +1 -0
- data/yard.rb +12 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3f7d4f5fc6ca3c627d4ad35b98c0f935d98a118
|
4
|
+
data.tar.gz: c3ea2e3558250ccc28c80ba638b511338ee2815f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdea171a98d780d43ff3d91b9375c646c997a1a12d0e2eb851974e731538637f82260c4d5b12b0d79d264fa37a4d60301b11b80ee6dffd829a2117e47d0a87e8
|
7
|
+
data.tar.gz: 145a2c7665ed69d6dcdeff8b82bb4d6972aa59456d0698fdf1e31e2b956286e8ec25f089bda951c564bac5ed16eca410f9f391d18030fa33ed35cee1e9f177da
|
@@ -309,6 +309,7 @@ extern "C" {
|
|
309
309
|
rb_define_method(rbHash, "[]", RUBY_METHOD_FUNC(hashGet), 1);
|
310
310
|
rb_define_method(rbHash, "each", RUBY_METHOD_FUNC(hashEach), 0);
|
311
311
|
rb_define_method(rbHash, "to_s", RUBY_METHOD_FUNC(hashToString), 0);
|
312
|
+
rb_define_method(rbHash, "inspect", RUBY_METHOD_FUNC(hashToString), 0);
|
312
313
|
rb_define_method(rbHash, "first", RUBY_METHOD_FUNC(hashFirst<ValueOrKey::BOTH>), 0);
|
313
314
|
rb_define_method(rbHash, "first_value", RUBY_METHOD_FUNC(hashFirst<ValueOrKey::VALUE>), 0);
|
314
315
|
rb_define_method(rbHash, "first_key", RUBY_METHOD_FUNC(hashFirst<ValueOrKey::KEY>), 0);
|
@@ -231,6 +231,7 @@ extern "C" {
|
|
231
231
|
rb_define_method(rbSet, "<<", RUBY_METHOD_FUNC(setAdd), 1);
|
232
232
|
rb_define_method(rbSet, "each", RUBY_METHOD_FUNC(setEach), 0);
|
233
233
|
rb_define_method(rbSet, "to_s", RUBY_METHOD_FUNC(setToString), 0);
|
234
|
+
rb_define_method(rbSet, "inspect", RUBY_METHOD_FUNC(setToString), 0);
|
234
235
|
rb_define_method(rbSet, "first", RUBY_METHOD_FUNC(setFirst), 0);
|
235
236
|
rb_define_method(rbSet, "last", RUBY_METHOD_FUNC(setLast), 0);
|
236
237
|
rb_define_method(rbSet, "delete", RUBY_METHOD_FUNC(setMutatingDelete), 1);
|
data/yard.rb
CHANGED
@@ -161,10 +161,14 @@ module RbLovely
|
|
161
161
|
# expect(hash[:y]).to equal 4
|
162
162
|
# expect(hash.length).to equal 3
|
163
163
|
# expect(hash.to_a).to eql [[:i, 1], [:y, 4], [:b, 16]]
|
164
|
+
#
|
165
|
+
# # reverse order by overriding key comparison function.
|
166
|
+
# rhash = RbLovely::SortedHash(compare: proc { |a, b| b <=> a })
|
164
167
|
class SortedHash
|
165
168
|
include Enumerable
|
166
169
|
|
167
170
|
# @complexity O(n).
|
171
|
+
# @see .[]
|
168
172
|
# @param content [Array] An array containing key, value, key, value ...
|
169
173
|
# @param compare [Proc] Comparison function used to order values (rather than default
|
170
174
|
# of using <=> method).
|
@@ -189,15 +193,18 @@ module RbLovely
|
|
189
193
|
# expect(hash.to_a).to eql [[:b, 1], [:a, 3]]
|
190
194
|
def self.[](*content) ; end
|
191
195
|
|
192
|
-
# Set the value associated with a key
|
196
|
+
# Set the value associated with a key, replacing the existing key's value.
|
193
197
|
# @complexity O(c).
|
198
|
+
# @see #replace
|
194
199
|
# @return The value that was passed.
|
195
200
|
# @example
|
196
201
|
# hash = RbLovely::SortedHash.new
|
197
202
|
# hash[:a] = 'yo'
|
198
203
|
def []=(key, value) ; end
|
199
204
|
|
200
|
-
# Set the value associated with a key
|
205
|
+
# Set the value associated with a key, differs to #[]= in return value.
|
206
|
+
# @complexity O(c).
|
207
|
+
# @see #[]=
|
201
208
|
# @return The value that was previously associated with the key or nil if the key was not present in the hash.
|
202
209
|
# @example
|
203
210
|
# hash = RbLovely::SortedHash[:a, 'yi']
|
@@ -222,7 +229,7 @@ module RbLovely
|
|
222
229
|
# hash.each { |key, value| puts "#{key} => #{value}" }
|
223
230
|
def each(&block) ; end
|
224
231
|
|
225
|
-
# Remove all
|
232
|
+
# Remove all key-value pairs from the hash.
|
226
233
|
# @complexity O(n)
|
227
234
|
# @example
|
228
235
|
# hash = RbLovely::SortedHash [:a, 10]
|
@@ -230,7 +237,8 @@ module RbLovely
|
|
230
237
|
# expect(hash.empty?).to equal true
|
231
238
|
def clear ; end
|
232
239
|
|
233
|
-
# Retrieve value
|
240
|
+
# Retrieve value from hash using key.
|
241
|
+
# @return Value associated with the corresponding key or nil if the key doesn't exist.
|
234
242
|
# @complexity O(c)
|
235
243
|
# @example
|
236
244
|
# hash = RbLovely::SortedHash [:a, 2]
|