xqsr3 0.8.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.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +27 -0
  3. data/README.md +26 -0
  4. data/lib/xqsr3/command_line_utilities/map_option_string.rb +137 -0
  5. data/lib/xqsr3/containers/frequency_map.rb +473 -0
  6. data/lib/xqsr3/containers/multi_map.rb +383 -0
  7. data/lib/xqsr3/diagnostics/exception_utilities.rb +216 -0
  8. data/lib/xqsr3/doc_.rb +116 -0
  9. data/lib/xqsr3/extensions/enumerable.rb +4 -0
  10. data/lib/xqsr3/extensions/enumerable/collect_with_index.rb +71 -0
  11. data/lib/xqsr3/extensions/enumerable/unique.rb +102 -0
  12. data/lib/xqsr3/extensions/io.rb +3 -0
  13. data/lib/xqsr3/extensions/io/writelines.rb +66 -0
  14. data/lib/xqsr3/extensions/kernel.rb +3 -0
  15. data/lib/xqsr3/extensions/kernel/raise_with_options.rb +68 -0
  16. data/lib/xqsr3/extensions/string.rb +5 -0
  17. data/lib/xqsr3/extensions/string/ends_with.rb +8 -0
  18. data/lib/xqsr3/extensions/string/map_option_string.rb +8 -0
  19. data/lib/xqsr3/extensions/string/starts_with.rb +8 -0
  20. data/lib/xqsr3/extensions/string/to_symbol.rb +8 -0
  21. data/lib/xqsr3/extensions/test/unit.rb +5 -0
  22. data/lib/xqsr3/extensions/test/unit/assert_eql.rb +18 -0
  23. data/lib/xqsr3/extensions/test/unit/assert_not.rb +18 -0
  24. data/lib/xqsr3/extensions/test/unit/assert_not_eql.rb +18 -0
  25. data/lib/xqsr3/io/writelines.rb +192 -0
  26. data/lib/xqsr3/quality/parameter_checking.rb +343 -0
  27. data/lib/xqsr3/string_utilities/ends_with.rb +134 -0
  28. data/lib/xqsr3/string_utilities/starts_with.rb +127 -0
  29. data/lib/xqsr3/string_utilities/to_symbol.rb +145 -0
  30. data/lib/xqsr3/version.rb +68 -0
  31. data/test/unit/command_line_utilities/tc_map_option_string.rb +39 -0
  32. data/test/unit/command_line_utilities/ts_all.rb +13 -0
  33. data/test/unit/containers/tc_frequency_map.rb +738 -0
  34. data/test/unit/containers/tc_multi_map.rb +640 -0
  35. data/test/unit/containers/ts_all.rb +13 -0
  36. data/test/unit/diagnostics/tc_exception_utilities.rb +221 -0
  37. data/test/unit/diagnostics/ts_all.rb +13 -0
  38. data/test/unit/extensions/enumerable/tc_collect_with_index.rb +36 -0
  39. data/test/unit/extensions/enumerable/tc_unique.rb +47 -0
  40. data/test/unit/extensions/enumerable/ts_all.rb +13 -0
  41. data/test/unit/extensions/io/tc_writelines.rb +110 -0
  42. data/test/unit/extensions/io/ts_all.rb +13 -0
  43. data/test/unit/extensions/kernel/tc_raise_with_options.rb +239 -0
  44. data/test/unit/extensions/kernel/ts_all.rb +13 -0
  45. data/test/unit/extensions/string/tc_ends_with.rb +70 -0
  46. data/test/unit/extensions/string/tc_map_option_string.rb +37 -0
  47. data/test/unit/extensions/string/tc_starts_with.rb +70 -0
  48. data/test/unit/extensions/string/tc_to_symbol.rb +51 -0
  49. data/test/unit/extensions/string/ts_all.rb +13 -0
  50. data/test/unit/extensions/ts_all.rb +13 -0
  51. data/test/unit/io/tc_writelines.rb +200 -0
  52. data/test/unit/io/ts_all.rb +13 -0
  53. data/test/unit/quality/tc_parameter_checking.rb +181 -0
  54. data/test/unit/quality/ts_all.rb +13 -0
  55. data/test/unit/tc_version.rb +37 -0
  56. data/test/unit/ts_all.rb +13 -0
  57. metadata +101 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 628985018fcc3f00bca980811128896add2e0565
4
+ data.tar.gz: 652a4e0cbfccfbb7d8c536eb17dda5c71a309727
5
+ SHA512:
6
+ metadata.gz: 88a5733f0303f191ea04ff83320b67073967d2b98b84fb9ec3ab94e3eb8919ddddd16e73b254f8da2db89ee26f76eef58d308c79ee6dac46dd7427d3f2770388
7
+ data.tar.gz: 940514fe49c658edcf9d001bfe5674e33904d149a638a3ea335933f148c5e870e273a42a6f7d5ab5e3ac74c6473fd4e65caa1fbb11942778318a00cafd6c8dd2
data/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ Copyright (c) 2016,
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ * Neither the name of xqsr3 nor the names of its
15
+ contributors may be used to endorse or promote products derived from
16
+ this software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # xqsr3
2
+ eXtensions by fine Quantum for Standard Ruby and 3rd-party libraries
3
+
4
+ ## Installation & usage
5
+
6
+ Install using `gem install xqsr3` or add it to your `Gemfile`.
7
+
8
+ ## Description
9
+
10
+ **xqsr3** is a lightweight, low-coupling library of assorted extensions to standard ruby and 3rd-party libraries.
11
+
12
+ ## Where to get help
13
+
14
+ [GitHub Page](https://github.com/synesissoftware/xqsr3 "GitHub Page")
15
+
16
+ ## Contribution guidelines
17
+
18
+ Defect reports, feature requests, and pull requests are welcome on https://github.com/synesissoftware/xqsr3.
19
+
20
+ ## Related projects
21
+
22
+ **xqsr3** is used in the **[libCLImate.Ruby](https://github.com/synesissoftware/libCLImate.Ruby)** library.
23
+
24
+ ## License
25
+
26
+ **xqsr3** is released under the 3-clause BSD license. See LICENSE for details.
@@ -0,0 +1,137 @@
1
+
2
+ # ######################################################################## #
3
+ # File: lib/xqsr3/command_line_utilities/map_option_string.rb
4
+ #
5
+ # Purpose: Definition of the ::Xqsr3::CommandLineUtilities::ToSymbol
6
+ # module
7
+ #
8
+ # Created: 15th April 2016
9
+ # Updated: 10th June 2016
10
+ #
11
+ # Home: http://github.com/synesissoftware/xqsr3
12
+ #
13
+ # Author: Matthew Wilson
14
+ #
15
+ # Copyright (c) 2016, Matthew Wilson and Synesis Software
16
+ # All rights reserved.
17
+ #
18
+ # Redistribution and use in source and binary forms, with or without
19
+ # modification, are permitted provided that the following conditions are
20
+ # met:
21
+ #
22
+ # * Redistributions of source code must retain the above copyright notice,
23
+ # this list of conditions and the following disclaimer.
24
+ #
25
+ # * Redistributions in binary form must reproduce the above copyright
26
+ # notice, this list of conditions and the following disclaimer in the
27
+ # documentation and/or other materials provided with the distribution.
28
+ #
29
+ # * Neither the names of the copyright holder nor the names of its
30
+ # contributors may be used to endorse or promote products derived from
31
+ # this software without specific prior written permission.
32
+ #
33
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
34
+ # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
35
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
36
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
37
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
38
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
39
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
40
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
41
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
42
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
43
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44
+ #
45
+ # ######################################################################## #
46
+
47
+
48
+
49
+ require 'xqsr3/string_utilities/to_symbol'
50
+
51
+ =begin
52
+ =end
53
+
54
+ module Xqsr3
55
+ module CommandLineUtilities
56
+
57
+ # Facilities for mapping strings to options
58
+ #
59
+ # === Components of interest
60
+ # * ::Xqsr3::CommandLineUtilities::MapOptionString.map_option_string
61
+ module MapOptionString
62
+
63
+ # :nodoc:
64
+ def self.included includer
65
+
66
+ raise TypeError, "module #{self} cannot be included into #{includer} because it does not respond to to_str" unless includer.method_defined? :to_str
67
+ end
68
+
69
+ private
70
+ # :nodoc:
71
+ module MapOptionString_Helper_ # :nodoc:
72
+
73
+ def self.map_option_string_with_options_ s, option_strings, options
74
+
75
+ h = {}
76
+
77
+ option_strings.each do |os|
78
+
79
+ t = os.dup
80
+ v = os.dup
81
+
82
+ if t =~ /\[.+?\]/
83
+
84
+ k = ''
85
+ v = ''
86
+
87
+ while t =~ /\[(.+?)\]/
88
+
89
+ k += $1
90
+ v += "#$`#$1"
91
+ t = $'
92
+ end
93
+
94
+ v += t
95
+ else
96
+
97
+ k = v
98
+ end
99
+
100
+ h[k] = v
101
+ h[v] = v
102
+ end
103
+
104
+ r = h[s]
105
+
106
+ if r
107
+
108
+ r = ::Xqsr3::StringUtilities::ToSymbol.string_to_symbol r
109
+ end
110
+
111
+ r
112
+ end
113
+ end
114
+ public
115
+
116
+ # Attempts to translate the value of a given string according
117
+ # to a collection of options strings
118
+ def self.map_option_string_from_string s, option_strings, options = {}
119
+
120
+ MapOptionString_Helper_.map_option_string_with_options_ s, option_strings, options
121
+ end
122
+
123
+ # Attempts to translate the (string) value of the receiver according
124
+ # to a collection of options strings
125
+ def map_option_string option_strings, options = {}
126
+
127
+ s = self.kind_of?(::String) ? self : self.to_str
128
+
129
+ MapOptionString_Helper_.map_option_string_with_options_ s, option_strings, options
130
+ end
131
+ end # module MapOptionString
132
+
133
+ end # module CommandLineUtilities
134
+ end # module Xqsr3
135
+
136
+ # ############################## end of file ############################# #
137
+
@@ -0,0 +1,473 @@
1
+
2
+ # ######################################################################## #
3
+ # File: lib/xqsr3/containers/frequency_map.rb
4
+ #
5
+ # Purpose: FrequencyMap container
6
+ #
7
+ # Created: 28th January 2005
8
+ # Updated: 10th June 2016
9
+ #
10
+ # Home: http://github.com/synesissoftware/xqsr3
11
+ #
12
+ # Author: Matthew Wilson
13
+ #
14
+ # Copyright (c) 2005-2016, Matthew Wilson and Synesis Software
15
+ # All rights reserved.
16
+ #
17
+ # Redistribution and use in source and binary forms, with or without
18
+ # modification, are permitted provided that the following conditions are
19
+ # met:
20
+ #
21
+ # * Redistributions of source code must retain the above copyright
22
+ # notice, this list of conditions and the following disclaimer.
23
+ #
24
+ # * Redistributions in binary form must reproduce the above copyright
25
+ # notice, this list of conditions and the following disclaimer in the
26
+ # documentation and/or other materials provided with the distribution.
27
+ #
28
+ # * Neither the names of the copyright holder nor the names of its
29
+ # contributors may be used to endorse or promote products derived from
30
+ # this software without specific prior written permission.
31
+ #
32
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
33
+ # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
34
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
36
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
39
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
+ #
44
+ # ######################################################################## #
45
+
46
+
47
+ =begin
48
+ =end
49
+
50
+ module Xqsr3
51
+ module Containers
52
+
53
+ class FrequencyMap
54
+
55
+ include Enumerable
56
+
57
+ ByElement = Class.new do
58
+
59
+ def self.[] *args
60
+
61
+ fm = FrequencyMap.new
62
+
63
+ args.each { |el| fm << el }
64
+
65
+ fm
66
+ end
67
+
68
+ private_class_method :new
69
+ end
70
+
71
+ def self.[] *args
72
+
73
+ return self.new if 0 == args.length
74
+
75
+ if 1 == args.length
76
+
77
+ arg = args[0]
78
+
79
+ case arg
80
+ when ::NilClass
81
+
82
+ return self.new
83
+ when ::Hash
84
+
85
+ fm = self.new
86
+ arg.each do |k, v|
87
+
88
+ fm.store k, v
89
+ end
90
+ return fm
91
+ when ::Array
92
+
93
+ # accepted forms:
94
+ #
95
+ # 1. Empty array
96
+ # 2. Array exclusively of two-element arrays
97
+ # 3. Array of even number of elements and at every odd index is an integer
98
+
99
+ # 1. Empty array
100
+
101
+ return self.new if arg.empty?
102
+
103
+ # 2. Array exclusively of two-element arrays
104
+
105
+ if arg.all? { |el| ::Array === el && 2 == el.size }
106
+
107
+ return self.[](::Hash.[]([ *arg ]))
108
+ end
109
+
110
+ # 3. Array of even number of elements and at every odd index is an integer
111
+
112
+ if (0 == (arg.size % 2)) && arg.each_with_index.select { |el, index| 1 == (index % 2) }.map(&:first).all? { |el| el.kind_of? ::Integer }
113
+
114
+ return self.[](::Hash.[](*arg))
115
+ end
116
+
117
+
118
+ raise ArgumentError, "array parameter not in an accepted form for subscript initialisation"
119
+ else
120
+
121
+ return self.[] arg.to_hash if arg.respond_to? :to_hash
122
+
123
+ raise TypeError, "given argument is neither a #{::Hash} nor an #{::Array} and does not respond to the to_hash method"
124
+ end
125
+
126
+ else
127
+
128
+ # treat all other argument permutations as having passed in an array
129
+
130
+ return self.[] [ *args ]
131
+ end
132
+ end
133
+
134
+ def initialize
135
+
136
+ @counts = {}
137
+ @count = 0
138
+ end
139
+
140
+ def << key
141
+
142
+ push key, 1
143
+ end
144
+
145
+ def == rhs
146
+
147
+ case rhs
148
+ when ::NilClass
149
+ return false
150
+ when ::Hash
151
+ return rhs.size == @counts.size && rhs == @counts
152
+ when self.class
153
+ return rhs.count == self.count && rhs == @counts
154
+ else
155
+ raise TypeError, "can compare #{self.class} only to instances of #{self.class} and #{::Hash}, but #{rhs.class} given"
156
+ end
157
+
158
+ false
159
+ end
160
+
161
+ def [] key
162
+
163
+ @counts[key]
164
+ end
165
+
166
+ def []= key, count
167
+
168
+ store key, count
169
+ end
170
+
171
+ def assoc key
172
+
173
+ @counts.assoc key
174
+ end
175
+
176
+ def clear
177
+
178
+ @counts.clear
179
+ @count = 0
180
+ end
181
+
182
+ # The total number of instances recorded
183
+ def count
184
+
185
+ @count
186
+ end
187
+
188
+ def default
189
+
190
+ @counts.default
191
+ end
192
+
193
+ def delete key
194
+
195
+ key_count = @counts.delete key
196
+
197
+ @count -= key_count if key_count
198
+ end
199
+
200
+ def dup
201
+
202
+ fm = self.class.new
203
+
204
+ fm.merge! self
205
+ end
206
+
207
+ def each
208
+
209
+ @counts.each do |k, v|
210
+
211
+ yield k, v
212
+ end
213
+ end
214
+
215
+ # Enumerates each entry pair - element + frequency - in descending
216
+ # order of frequency
217
+ #
218
+ # Note: this method is expensive, as it must create a new dictionary
219
+ # and map all entries into it in order to achieve the ordering
220
+ def each_by_frequency
221
+
222
+ tm = {}
223
+ @counts.each do |element, frequency|
224
+
225
+ if not tm.has_key? frequency
226
+
227
+ tm[frequency] = [element]
228
+ else
229
+
230
+ tm[frequency].push element
231
+ end
232
+ end
233
+
234
+ keys = tm.keys.sort.reverse
235
+ keys.each do |frequency|
236
+
237
+ elements = tm[frequency].sort
238
+ elements.each do |element|
239
+
240
+ yield element, frequency
241
+ end
242
+ end
243
+ end
244
+
245
+ def each_key
246
+
247
+ keys.each do |element|
248
+
249
+ yield element
250
+ end
251
+ end
252
+
253
+ alias each_pair each
254
+
255
+ def each_value
256
+
257
+ keys.each do |element|
258
+
259
+ yield @counts[element]
260
+ end
261
+ end
262
+
263
+ def empty?
264
+
265
+ 0 == size
266
+ end
267
+
268
+ def eql? rhs
269
+
270
+ case rhs
271
+ when self.class
272
+ return self == rhs
273
+ else
274
+ return false
275
+ end
276
+ end
277
+
278
+ def fetch key, default = nil, &block
279
+
280
+ case default
281
+ when ::NilClass, ::Integer
282
+ ;
283
+ else
284
+ raise TypeError, "default parameter ('#{default}') must be of type #{::Integer}, but was of type #{default.class}"
285
+ end
286
+
287
+ unless @counts.has_key? key
288
+
289
+ return default unless default.nil?
290
+
291
+ if block_given?
292
+
293
+ case block.arity
294
+ when 0
295
+ return yield
296
+ when 1
297
+ return yield key
298
+ else
299
+ raise ArgumentError, "given block must take a single parameter - #{block.arity} given"
300
+ end
301
+ end
302
+
303
+ raise KeyError, "given key '#{key}' (#{key.class}) does not exist"
304
+ end
305
+
306
+ @counts[key]
307
+ end
308
+
309
+ def flatten
310
+
311
+ @counts.flatten
312
+ end
313
+
314
+ def has_key? key
315
+
316
+ @counts.has_key? key
317
+ end
318
+
319
+ def has_value? value
320
+
321
+ case value
322
+ when ::NilClass, ::Integer
323
+ ;
324
+ else
325
+ raise TypeError, "parameter ('#{value}') must be of type #{::Integer}, but was of type #{value.class}"
326
+ end
327
+
328
+ @counts.has_value? value
329
+ end
330
+
331
+ def hash
332
+
333
+ @counts.hash
334
+ end
335
+
336
+ alias include? has_key?
337
+
338
+ def inspect
339
+
340
+ @counts.inspect
341
+ end
342
+
343
+ # def keep_if
344
+ #
345
+ # @counts.keep_if
346
+ # end
347
+
348
+ def key value
349
+
350
+ case value
351
+ when ::NilClass, ::Integer
352
+ ;
353
+ else
354
+ raise TypeError, "parameter ('#{value}') must be of type #{::Integer}, but was of type #{value.class}"
355
+ end
356
+
357
+ @counts.key value
358
+ end
359
+
360
+ alias key? has_key?
361
+
362
+ def keys
363
+
364
+ @counts.keys
365
+ end
366
+
367
+ def length
368
+
369
+ @counts.length
370
+ end
371
+
372
+ alias member? has_key?
373
+
374
+ def merge fm
375
+
376
+ raise TypeError, "parameter must be an instance of type #{self.class}" unless fm.instance_of? self.class
377
+
378
+ fm_new = self.class.new
379
+
380
+ fm_new.merge! self
381
+ fm_new.merge! fm
382
+
383
+ fm_new
384
+ end
385
+
386
+ def merge! fm
387
+
388
+ fm.each do |k, v|
389
+
390
+ if not @counts.has_key? k
391
+
392
+ @counts[k] = v
393
+ else
394
+
395
+ @counts[k] += v
396
+ end
397
+ @count += v
398
+ end
399
+
400
+ self
401
+ end
402
+
403
+ def push element, count = 1
404
+
405
+ raise TypeError, "count ('#{count}') must in an instance of #{::Integer}, but #{count.class} provided" unless count.kind_of? ::Integer
406
+
407
+ if not @counts.has_key? element
408
+
409
+ @counts[element] = count
410
+ else
411
+
412
+ @counts[element] += count
413
+ end
414
+ @count += count
415
+
416
+ self
417
+ end
418
+
419
+ def shift
420
+
421
+ r = @counts.shift
422
+
423
+ @count -= r[1] if ::Array === r
424
+
425
+ r
426
+ end
427
+
428
+ alias size length
429
+
430
+ def store key, value
431
+
432
+ case value
433
+ when ::NilClass, ::Integer
434
+ ;
435
+ else
436
+ raise TypeError, "value ('#{value}') must be of type #{::Integer}, but was of type #{value.class}"
437
+ end
438
+
439
+ key_count = @counts[key] || 0
440
+
441
+ @counts.store key, value
442
+
443
+ @count += value - key_count
444
+ end
445
+
446
+ def to_a
447
+
448
+ @counts.to_a
449
+ end
450
+
451
+ def to_h
452
+
453
+ @counts.to_h
454
+ end
455
+
456
+ def to_hash
457
+
458
+ @counts.to_hash
459
+ end
460
+
461
+ alias to_s inspect
462
+
463
+ def values
464
+
465
+ @counts.values
466
+ end
467
+ end # class FrequencyMap
468
+
469
+ end # module Containers
470
+ end # module Xqsr3
471
+
472
+ # ############################## end of file ############################# #
473
+