rb_lovely 0.6.4 → 0.6.5

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f77c4e7bc0c9011e9fac59b5c509836c1217661
4
- data.tar.gz: abeb9c72ab3f9c8a636986fb792639fb922c3409
3
+ metadata.gz: fbacf68a03009f39933493ff077a97ace08685c0
4
+ data.tar.gz: 4c8d5d57b559c93215e7b9be01c95fb3c6073e40
5
5
  SHA512:
6
- metadata.gz: 424beddca21eba29ed7e03d7bc61c071d4f29eeced343c4160a0259ef3132249b84b6c29293d27ccb755cb44fd14e4a9f49f0aa053534de9856ba532f5b44068
7
- data.tar.gz: 5df6f7524c57ad2b0dbe6753f8b4c4ec6d2f50dfc387a6a0894f43172952bc2cf102c76fa546a266851099302791c9f1292fa361a064da4cb911a66314521a75
6
+ metadata.gz: 6b457ed98975e79f3d567f32c5ba42efa38df04400918908d3213f2a5461133044f4dcde5f6565e0b57fe6364aeecfd607d1c34582c57f9b251ca132eaf51392
7
+ data.tar.gz: 0402307048f4051120ccc841dc86e1971de96cfe4c927c67ad0c0c084219ca765a797c0a40944cbd7b15564ffe69015555ad89c7698b3c0e6eae866bf526781a
data/.yardopts CHANGED
@@ -1 +1 @@
1
- yard.rb
1
+ yard.rb --tag complexity:"Complexity"
@@ -60,6 +60,11 @@ VALUE hashLength(VALUE self) {
60
60
  return INT2NUM(hash->container.size());
61
61
  }
62
62
 
63
+ VALUE hashEmpty(VALUE self) {
64
+ Hash* hash = rubyCast<Hash>(self);
65
+ return hash->container.empty() ? Qtrue : Qfalse;
66
+ }
67
+
63
68
  VALUE hashInitialize(int argc, VALUE *argv, VALUE self) {
64
69
  Hash* hash = rubyCast<Hash>(self);
65
70
  if (argc == 1) {
@@ -255,6 +260,7 @@ extern "C" {
255
260
  rb_define_singleton_method(rbHash, "[]", RUBY_METHOD_FUNC(hashFactory), -2);
256
261
  rb_define_method(rbHash, "clear", RUBY_METHOD_FUNC(hashClear), 0);
257
262
  rb_define_method(rbHash, "length", RUBY_METHOD_FUNC(hashLength), 0);
263
+ rb_define_method(rbHash, "empty?", RUBY_METHOD_FUNC(hashEmpty), 0);
258
264
  rb_define_method(rbHash, "[]=", RUBY_METHOD_FUNC(hashUpdate), 2);
259
265
  // like []= but return previous value if there was one
260
266
  rb_define_method(rbHash, "replace", RUBY_METHOD_FUNC(hashReplace), 2);
@@ -52,6 +52,11 @@ VALUE setLength(VALUE self) {
52
52
  return INT2NUM(set->size());
53
53
  }
54
54
 
55
+ VALUE setEmpty(VALUE self) {
56
+ Set* set = rubyCast<Set>(self);
57
+ return set->empty() ? Qtrue : Qfalse;
58
+ }
59
+
55
60
  VALUE setAdd(VALUE self, VALUE val) {
56
61
  Set* set = rubyCast<Set>(self);
57
62
  set->insert(val);
@@ -221,6 +226,7 @@ extern "C" {
221
226
  rb_define_singleton_method(rbSet, "[]", RUBY_METHOD_FUNC(setFactory), -2);
222
227
  rb_define_method(rbSet, "clear", RUBY_METHOD_FUNC(setClear), 0);
223
228
  rb_define_method(rbSet, "length", RUBY_METHOD_FUNC(setLength), 0);
229
+ rb_define_method(rbSet, "empty?", RUBY_METHOD_FUNC(setEmpty), 0);
224
230
  rb_define_method(rbSet, "add", RUBY_METHOD_FUNC(setAdd), 1);
225
231
  rb_define_method(rbSet, "<<", RUBY_METHOD_FUNC(setAdd), 1);
226
232
  rb_define_method(rbSet, "each", RUBY_METHOD_FUNC(setEach), 0);
data/yard.rb CHANGED
@@ -68,14 +68,6 @@ module RbLovely
68
68
  # expect(set.first).to equal 0
69
69
  def first ; end
70
70
 
71
- # Remove the first element from the set.
72
- # @complexity O(c).
73
- # @return The first value according to the <=> method defined on each member or nil if the set is empty.
74
- # @example
75
- # set = RbLovely::SortedSet [4, 0, 2]
76
- # expect(set.shift).to equal 0
77
- def shift ; end
78
-
79
71
  # Access the last element in the set.
80
72
  # @complexity O(c).
81
73
  # @return The last value according to the <=> method defined on each member.
@@ -84,7 +76,17 @@ module RbLovely
84
76
  # expect(set.last).to equal 4
85
77
  def last ; end
86
78
 
79
+ # Remove the first element from the set.
80
+ # @see #pop
81
+ # @complexity O(c).
82
+ # @return The first value according to the <=> method defined on each member or nil if the set is empty.
83
+ # @example
84
+ # set = RbLovely::SortedSet [4, 0, 2]
85
+ # expect(set.shift).to equal 0
86
+ def shift ; end
87
+
87
88
  # Remove the last element from the set.
89
+ # @see #shift
88
90
  # @complexity O(c).
89
91
  # @return The last value according to the <=> method defined on each member or nil if the set is empty.
90
92
  # @example
@@ -125,6 +127,14 @@ module RbLovely
125
127
  # set = RbLovely::SortedSet [0, 1, 2, 3]
126
128
  # set.each { |x| puts x }
127
129
  def each(&block) ; end
130
+
131
+ # Gets the number of elements in the set.
132
+ # @return [Number] Number of items in set.
133
+ def length ; end
134
+
135
+ # Return true if the set is empty.
136
+ # @return [Boolean] True only if the set is empty else false.
137
+ def empty? ; end
128
138
  end
129
139
 
130
140
 
@@ -206,7 +216,7 @@ module RbLovely
206
216
  # @example
207
217
  # hash = RbLovely::SortedHash [:a, 10]
208
218
  # hash.clear
209
- # expect(hash.length).to equal 0
219
+ # expect(hash.empty?).to equal true
210
220
  def clear ; end
211
221
 
212
222
  # Retrieve value associated with the corresponding key or nil if the key doesn't exist.
@@ -219,13 +229,41 @@ module RbLovely
219
229
 
220
230
  # Return true if the key is contained in the hash.
221
231
  def include?(key) ; end
232
+ alias :has_key? :include?
233
+ alias :key? :include?
222
234
 
223
235
  # Retrieve first value as determined by value sort order or nil if the hash is empty.
236
+ # @complexity O(c)
224
237
  def first ; end
225
238
 
226
239
  # Retrieve last value as determined by value sort order or nil if the hash is empty.
240
+ # @complexity O(c)
227
241
  def last ; end
228
242
 
229
- alias :has_key? :include?
243
+ # Remove the first value in the hash and return it or return nil if the hash is empty.
244
+ # @complexity O(c).
245
+ # @see #pop
246
+ # @return The first value according to the <=> method defined on each member or nil if the hash is empty.
247
+ # @example
248
+ # set = RbLovely::SortedHash [:a, 2, :b, 10]
249
+ # expect(hash.shift).to equal 2
250
+ def shift ; end
251
+
252
+ # Remove the last value in the hash and return it or return nil if the hash is empty.
253
+ # @complexity O(c).
254
+ # @see #shift
255
+ # @return The last value according to the <=> method defined on each member or nil if the hash is empty.
256
+ # @example
257
+ # set = RbLovely::SortedHash [:a, 2, :b, 10]
258
+ # expect(hash.pop).to equal 10
259
+ def pop ; end
260
+
261
+ # Gets the number of elements in the hash.
262
+ # @return [Number] Number of items in hash.
263
+ def length ; end
264
+
265
+ # Return true if the hash is empty.
266
+ # @return [Boolean] True only if the hash is empty else false.
267
+ def empty? ; end
230
268
  end
231
269
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rb_lovely
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Pike