ds 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +11 -0
  3. data/.rubocop_todo.yml +452 -0
  4. data/.travis.yml +12 -0
  5. data/Gemfile +1 -1
  6. data/README.rdoc +185 -214
  7. data/Rakefile +8 -3
  8. data/ds.gemspec +16 -13
  9. data/lib/ds.rb +20 -30
  10. data/lib/ds/{matrixes → arrays}/array_2d.rb +9 -10
  11. data/lib/ds/arrays/expandable_array.rb +34 -0
  12. data/lib/ds/arrays/heap_store.rb +32 -0
  13. data/lib/ds/arrays/tri_matrix.rb +33 -0
  14. data/lib/ds/lists/list.rb +310 -186
  15. data/lib/ds/lists/list_element.rb +14 -11
  16. data/lib/ds/pair.rb +4 -4
  17. data/lib/ds/queues/priority_queue.rb +33 -20
  18. data/lib/ds/queues/simple_queue.rb +55 -0
  19. data/lib/ds/sets/indexed_set.rb +37 -0
  20. data/lib/ds/stacks/stack.rb +25 -17
  21. data/lib/ds/trees/binary_heap.rb +71 -66
  22. data/lib/ds/trees/binary_tree.rb +40 -44
  23. data/lib/ds/trees/red_black_tree.rb +123 -0
  24. data/lib/ds/trees/red_black_tree/node.rb +21 -0
  25. data/lib/ds/trees/tree.rb +50 -48
  26. data/lib/ds/trees/tree_walker.rb +73 -144
  27. data/lib/ds/trees/trie.rb +67 -37
  28. data/lib/ds/trees/trie/node.rb +48 -0
  29. data/lib/ds/version.rb +2 -1
  30. data/test/help.rb +3 -6
  31. data/test/performance/binary_heap_performance_test.rb +20 -0
  32. data/test/performance/list_performance_test.rb +36 -0
  33. data/test/performance/priority_queue_performance.rb +32 -0
  34. data/test/performance/rbt_performance_test.rb +17 -0
  35. data/test/performance/simple_queue_performance_test.rb +37 -0
  36. data/test/performance/stack_test.rb +45 -0
  37. data/test/test_array2d.rb +29 -31
  38. data/test/test_binary_heap.rb +29 -23
  39. data/test/test_binary_tree.rb +30 -20
  40. data/test/test_expandable_array.rb +6 -10
  41. data/test/test_heap_store.rb +34 -0
  42. data/test/test_indexed_set.rb +26 -0
  43. data/test/test_list.rb +226 -109
  44. data/test/test_list_element.rb +34 -16
  45. data/test/test_pair.rb +5 -8
  46. data/test/test_priority_queue.rb +43 -64
  47. data/test/test_queue.rb +12 -61
  48. data/test/test_red_black_tree.rb +46 -0
  49. data/test/test_stack.rb +35 -39
  50. data/test/test_tree.rb +42 -29
  51. data/test/test_tree_walker.rb +27 -52
  52. data/test/test_tri_matrix.rb +6 -11
  53. data/test/test_trie.rb +59 -17
  54. metadata +80 -35
  55. data/lib/ds/ext/array_x.rb +0 -35
  56. data/lib/ds/graphs/digraph.rb +0 -20
  57. data/lib/ds/graphs/edge.rb +0 -15
  58. data/lib/ds/graphs/graph.rb +0 -111
  59. data/lib/ds/graphs/graph_as_matrix.rb +0 -113
  60. data/lib/ds/graphs/graph_as_tri_matrix.rb +0 -24
  61. data/lib/ds/lists/cyclic_list.rb +0 -21
  62. data/lib/ds/lists/ring.rb +0 -42
  63. data/lib/ds/matrixes/expandable_array.rb +0 -37
  64. data/lib/ds/matrixes/tri_matrix.rb +0 -30
  65. data/lib/ds/queues/queue.rb +0 -53
  66. data/lib/ds/sets/ordered_set.rb +0 -32
  67. data/lib/ds/trees/binary_search_tree.rb +0 -34
  68. data/lib/ds/trees/complete_binary_tree.rb +0 -60
  69. data/test/test_array_x.rb +0 -51
  70. data/test/test_binary_search_tree.rb +0 -39
  71. data/test/test_complete_binary_tree.rb +0 -58
  72. data/test/test_digraph.rb +0 -134
  73. data/test/test_graph.rb +0 -80
  74. data/test/test_ordered_set.rb +0 -28
  75. data/test/test_ring.rb +0 -28
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d82d8b78c713c1df3c2a90ffba31fbb3cc0ec832
4
+ data.tar.gz: 852f880007ed7ea444aeed7754793510f39c370b
5
+ SHA512:
6
+ metadata.gz: dbfa87fdd20983378f200df765f5f5b9869539d4e5bf038cabe90e746b7b897b24d48d917d5e85980bb6494748b46d3424af903e530aee61a69fd271c2c4a334
7
+ data.tar.gz: f9fa767205e56d6424dbe304db426dd19673716cf2335cdde7c7f960128f65fece05208dd24d79f69dcf6b548f1189e412aa409eb41601275b83aa8adf222cee
@@ -0,0 +1,11 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Metrics/ClassLength:
4
+ Max: 250
5
+
6
+ Metrics/LineLength:
7
+ Max: 110
8
+
9
+ Metrics/MethodLength:
10
+ Max: 15
11
+
@@ -0,0 +1,452 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-01-12 21:46:11 +0100 using RuboCop version 0.35.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 3
10
+ # Lint/AmbiguousOperator:
11
+ # Exclude:
12
+ # - 'lib/ds/graphs/graph.rb'
13
+ # - 'lib/ds/trees/tree_walker.rb'
14
+ #
15
+ # Offense count: 3
16
+ # Configuration parameters: AllowSafeAssignment.
17
+ # Lint/AssignmentInCondition:
18
+ # Exclude:
19
+ # - 'lib/ds/lists/list.rb'
20
+ # - 'lib/ds/queues/priority_queue.rb'
21
+ # - 'lib/ds/sets/ordered_set.rb'
22
+ #
23
+ # Offense count: 1
24
+ # Cop supports --auto-correct.
25
+ # Lint/BlockAlignment:
26
+ # Exclude:
27
+ # - 'test/test_tree.rb'
28
+ #
29
+ # Offense count: 5
30
+ # Cop supports --auto-correct.
31
+ # Configuration parameters: IgnoreEmptyBlocks.
32
+ # Lint/UnusedBlockArgument:
33
+ # Exclude:
34
+ # - 'lib/ds/trees/tree.rb'
35
+ # - 'test/test_list.rb'
36
+ # - 'test/test_priority_queue.rb'
37
+ # - 'test/test_queue.rb'
38
+ # - 'test/test_stack.rb'
39
+ #
40
+ # Offense count: 1
41
+ # Cop supports --auto-correct.
42
+ # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
43
+ # Lint/UnusedMethodArgument:
44
+ # Exclude:
45
+ # - 'lib/ds/trees/tree.rb'
46
+ #
47
+ # Offense count: 9
48
+ # Lint/UselessAssignment:
49
+ # Exclude:
50
+ # - 'lib/ds/lists/list.rb'
51
+ # - 'lib/ds/trees/tree.rb'
52
+ # - 'lib/ds/trees/tree_walker.rb'
53
+ # - 'lib/ds/trees/trie.rb'
54
+ # - 'test/test_binary_search_tree.rb'
55
+ # - 'test/test_list.rb'
56
+ #
57
+ # Offense count: 8
58
+ # Metrics/AbcSize:
59
+ # Max: 26
60
+ #
61
+ # Offense count: 2
62
+ # Configuration parameters: CountComments.
63
+ # Metrics/ClassLength:
64
+ # Max: 192
65
+ #
66
+ # Offense count: 3
67
+ # Metrics/CyclomaticComplexity:
68
+ # Max: 9
69
+ #
70
+ # Offense count: 30
71
+ # Configuration parameters: AllowURI, URISchemes.
72
+ # Metrics/LineLength:
73
+ # Max: 106
74
+ #
75
+ # Offense count: 14
76
+ # Configuration parameters: CountComments.
77
+ # Metrics/MethodLength:
78
+ # Max: 31
79
+ #
80
+ # Offense count: 2
81
+ # Metrics/PerceivedComplexity:
82
+ # Max: 10
83
+
84
+ # Offense count: 4
85
+ # Cop supports --auto-correct.
86
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
87
+ # Style/AndOr:
88
+ # Exclude:
89
+ # - 'lib/ds/graphs/graph_as_matrix.rb'
90
+ # - 'lib/ds/trees/tree.rb'
91
+ # - 'lib/ds/trees/tree_walker.rb'
92
+ #
93
+ # Offense count: 1
94
+ # Cop supports --auto-correct.
95
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
96
+ # Style/BracesAroundHashParameters:
97
+ # Exclude:
98
+ # - 'test/test_list.rb'
99
+ #
100
+ # Offense count: 1
101
+ # Style/CaseEquality:
102
+ # Exclude:
103
+ # - 'lib/ds/graphs/graph.rb'
104
+ #
105
+ # Offense count: 1
106
+ # Cop supports --auto-correct.
107
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
108
+ # Style/ClassCheck:
109
+ # Exclude:
110
+ # - 'lib/ds/trees/tree_walker.rb'
111
+ #
112
+ # Offense count: 10
113
+ # Configuration parameters: Exclude.
114
+ # Style/Documentation:
115
+ # Exclude:
116
+ # - 'spec/**/*'
117
+ # - 'test/**/*'
118
+ # - 'lib/ds/graphs/digraph.rb'
119
+ # - 'lib/ds/graphs/edge.rb'
120
+ # - 'lib/ds/graphs/graph.rb'
121
+ # - 'lib/ds/graphs/graph_as_matrix.rb'
122
+ # - 'lib/ds/graphs/graph_as_tri_matrix.rb'
123
+ # - 'lib/ds/trees/binary_tree.rb'
124
+ # - 'lib/ds/trees/tree.rb'
125
+ # - 'lib/ds/trees/tree_walker.rb'
126
+ # - 'lib/ds/trees/trie.rb'
127
+ # - 'lib/ds/version.rb'
128
+ #
129
+ # Offense count: 1
130
+ # Style/DoubleNegation:
131
+ # Exclude:
132
+ # - 'lib/ds/lists/list.rb'
133
+ #
134
+ # Offense count: 2
135
+ # Cop supports --auto-correct.
136
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
137
+ # Style/EmptyElse:
138
+ # Exclude:
139
+ # - 'lib/ds/graphs/graph_as_matrix.rb'
140
+ # - 'lib/ds/trees/trie.rb'
141
+ #
142
+ # Offense count: 43
143
+ # Cop supports --auto-correct.
144
+ # Style/EmptyLines:
145
+ # Enabled: false
146
+
147
+ # Offense count: 1
148
+ # Cop supports --auto-correct.
149
+ # Style/EmptyLinesAroundAccessModifier:
150
+ # Exclude:
151
+ # - 'lib/ds/trees/trie.rb'
152
+
153
+ # Offense count: 63
154
+ # Cop supports --auto-correct.
155
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
156
+ # Style/EmptyLinesAroundBlockBody:
157
+ # Enabled: false
158
+
159
+ # Offense count: 12
160
+ # Cop supports --auto-correct.
161
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
162
+ # Style/EmptyLinesAroundClassBody:
163
+ # Exclude:
164
+ # - 'lib/ds/graphs/digraph.rb'
165
+ # - 'lib/ds/graphs/edge.rb'
166
+ # - 'lib/ds/graphs/graph.rb'
167
+ # - 'lib/ds/graphs/graph_as_matrix.rb'
168
+ # - 'lib/ds/graphs/graph_as_tri_matrix.rb'
169
+ # - 'lib/ds/trees/tree.rb'
170
+ # - 'lib/ds/trees/tree_walker.rb'
171
+ # - 'lib/ds/trees/trie.rb'
172
+ #
173
+ # Offense count: 3
174
+ # Cop supports --auto-correct.
175
+ # Style/EmptyLinesAroundMethodBody:
176
+ # Exclude:
177
+ # - 'lib/ds/trees/tree_walker.rb'
178
+
179
+ # Offense count: 1
180
+ # Cop supports --auto-correct.
181
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
182
+ # Style/EmptyLinesAroundModuleBody:
183
+ # Exclude:
184
+ # - 'lib/ds/matrixes/expandable_array.rb'
185
+
186
+ # Offense count: 19
187
+ # Cop supports --auto-correct.
188
+ # Configuration parameters: AllowForAlignment.
189
+ # Style/ExtraSpacing:
190
+ # Exclude:
191
+ # - 'lib/ds/graphs/edge.rb'
192
+ # - 'lib/ds/graphs/graph.rb'
193
+ # - 'lib/ds/graphs/graph_as_matrix.rb'
194
+ # - 'lib/ds/trees/tree_walker.rb'
195
+ # - 'test/test_binary_heap.rb'
196
+ # - 'test/test_list.rb'
197
+ # - 'test/test_priority_queue.rb'
198
+ # - 'test/test_stack.rb'
199
+ # - 'test/test_tree_walker.rb'
200
+ #
201
+ # Offense count: 4
202
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
203
+ # Style/For:
204
+ # Enabled: false
205
+ #
206
+ #Offense count: 7
207
+ #Configuration parameters: MinBodyLength.
208
+ # Style/GuardClause:
209
+ # Exclude:
210
+ # - 'lib/ds/graphs/graph_as_matrix.rb'
211
+ # - 'lib/ds/matrixes/expandable_array.rb'
212
+ # - 'lib/ds/trees/binary_heap.rb'
213
+ # - 'lib/ds/trees/tree.rb'
214
+ # - 'lib/ds/trees/tree_walker.rb'
215
+ #
216
+ # Offense count: 1
217
+ # Cop supports --auto-correct.
218
+ # Configuration parameters: SupportedStyles, UseHashRocketsWithSymbolValues.
219
+ # Style/HashSyntax:
220
+ # EnforcedStyle: hash_rockets
221
+ #
222
+ # Offense count: 2
223
+ # Cop supports --auto-correct.
224
+ # Configuration parameters: MaxLineLength.
225
+ # Style/IfUnlessModifier:
226
+ # Exclude:
227
+ # - 'lib/ds/graphs/graph_as_matrix.rb'
228
+ # - 'lib/ds/trees/tree_walker.rb'
229
+ #
230
+ # Offense count: 3
231
+ # Cop supports --auto-correct.
232
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
233
+ # Style/IndentationConsistency:
234
+ # Exclude:
235
+ # - 'lib/ds/trees/tree_walker.rb'
236
+ # - 'test/test_tree.rb'
237
+ #
238
+ # Offense count: 2
239
+ # Cop supports --auto-correct.
240
+ # Configuration parameters: Width.
241
+ # Style/IndentationWidth:
242
+ # Exclude:
243
+ # - 'lib/ds/trees/tree.rb'
244
+ # - 'test/test_tree.rb'
245
+ #
246
+ # Offense count: 43
247
+ # Cop supports --auto-correct.
248
+ # Style/LeadingCommentSpace:
249
+ # Exclude:
250
+ # - 'Rakefile'
251
+ # - 'lib/ds/graphs/digraph.rb'
252
+ # - 'lib/ds/graphs/edge.rb'
253
+ # - 'lib/ds/graphs/graph.rb'
254
+ # - 'lib/ds/graphs/graph_as_matrix.rb'
255
+ # - 'lib/ds/graphs/graph_as_tri_matrix.rb'
256
+ # - 'lib/ds/trees/tree.rb'
257
+ # - 'lib/ds/trees/tree_walker.rb'
258
+ #
259
+ # Offense count: 11
260
+ # Cop supports --auto-correct.
261
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
262
+ # Style/MethodDefParentheses:
263
+ # Enabled: false
264
+ #
265
+ # Offense count: 1
266
+ # Cop supports --auto-correct.
267
+ # Style/NegatedWhile:
268
+ # Exclude:
269
+ # - 'lib/ds/graphs/graph.rb'
270
+ #
271
+ # Offense count: 1
272
+ # Cop supports --auto-correct.
273
+ # # Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
274
+ # Style/Next:
275
+ # Exclude:
276
+ # - 'lib/ds/graphs/graph.rb'
277
+ #
278
+ # Offense count: 4
279
+ # Cop supports --auto-correct.
280
+ # Style/NumericLiterals:
281
+ # MinDigits: 7
282
+ #
283
+ # Offense count: 2
284
+ # Cop supports --auto-correct.
285
+ # Style/ParallelAssignment:
286
+ # Exclude:
287
+ # - 'lib/ds/trees/binary_heap.rb'
288
+
289
+ # Offense count: 2
290
+ # Cop supports --auto-correct.
291
+ # Configuration parameters: PreferredDelimiters.
292
+ # Style/PercentLiteralDelimiters:
293
+ # Exclude:
294
+ # - 'ds.gemspec'
295
+ # - 'lib/ds/trees/trie.rb'
296
+ #
297
+ # Offense count: 3
298
+ # Cop supports --auto-correct.
299
+ # Configuration parameters: AllowMultipleReturnValues.
300
+ # Style/RedundantReturn:
301
+ # Exclude:
302
+ # - 'lib/ds/trees/tree.rb'
303
+ # - 'lib/ds/trees/tree_walker.rb'
304
+ #
305
+ # Offense count: 9
306
+ # Cop supports --auto-correct.
307
+ # Style/RedundantSelf:
308
+ # Exclude:
309
+ # - 'lib/ds/trees/binary_tree.rb'
310
+ # - 'lib/ds/trees/tree.rb'
311
+ # - 'lib/ds/trees/tree_walker.rb'
312
+ #
313
+ # Offense count: 3
314
+ # Cop supports --auto-correct.
315
+ # Style/SelfAssignment:
316
+ # Exclude:
317
+ # - 'lib/ds/trees/tree_walker.rb'
318
+ # - 'test/test_list.rb'
319
+ #
320
+ # Offense count: 1
321
+ # Cop supports --auto-correct.
322
+ # Configuration parameters: AllowAsExpressionSeparator.
323
+ # Style/Semicolon:
324
+ # Exclude:
325
+ # - 'test/test_trie.rb'
326
+
327
+ # Offense count: 5
328
+ # Cop supports --auto-correct.
329
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
330
+ # Style/SignalException:
331
+ # Exclude:
332
+ # - 'lib/ds/trees/tree_walker.rb'
333
+ # - 'lib/ds/trees/trie.rb'
334
+ #
335
+ # Offense count: 3
336
+ # Configuration parameters: Methods.
337
+ # Style/SingleLineBlockParams:
338
+ # Exclude:
339
+ # - 'lib/ds/trees/tree.rb'
340
+ # - 'lib/ds/trees/tree_walker.rb'
341
+ # - 'test/test_list.rb'
342
+ #
343
+ # Offense count: 9
344
+ # Cop supports --auto-correct.
345
+ # Style/SingleSpaceBeforeFirstArg:
346
+ # Exclude:
347
+ # - 'test/test_binary_heap.rb'
348
+ # - 'test/test_list.rb'
349
+ # - 'test/test_stack.rb'
350
+ # - 'test/test_tree_walker.rb'
351
+ #
352
+ # Offense count: 500
353
+ # Cop supports --auto-correct.
354
+ # Style/SpaceAfterComma:
355
+ # Enabled: false
356
+ #
357
+ # Offense count: 1
358
+ # Cop supports --auto-correct.
359
+ # Style/SpaceAfterMethodName:
360
+ # Exclude:
361
+ # - 'lib/ds/trees/tree.rb'
362
+ #
363
+ # Offense count: 16
364
+ # Cop supports --auto-correct.
365
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
366
+ # Style/SpaceAroundEqualsInParameterDefault:
367
+ # Enabled: false
368
+
369
+ # Offense count: 9
370
+ # Cop supports --auto-correct.
371
+ # Configuration parameters: MultiSpaceAllowedForOperators.
372
+ # Style/SpaceAroundOperators:
373
+ # Exclude:
374
+ # - 'lib/ds/graphs/graph_as_matrix.rb'
375
+ # - 'lib/ds/trees/tree.rb'
376
+ # - 'lib/ds/trees/tree_walker.rb'
377
+ # - 'lib/ds/trees/trie.rb'
378
+ # - 'test/test_list.rb'
379
+ #
380
+ # Offense count: 31
381
+ # Cop supports --auto-correct.
382
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
383
+ # Style/SpaceBeforeBlockBraces:
384
+ # Enabled: false
385
+ #
386
+ # Offense count: 47
387
+ # Cop supports --auto-correct.
388
+ # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
389
+ # Style/SpaceInsideBlockBraces:
390
+ # Enabled: false
391
+ #
392
+ # Offense count: 1
393
+ # Cop supports --auto-correct.
394
+ # Style/SpaceInsideBrackets:
395
+ # Exclude:
396
+ # - 'test/test_graph.rb'
397
+ #
398
+ # Offense count: 2
399
+ # Cop supports --auto-correct.
400
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
401
+ # Style/SpaceInsideHashLiteralBraces:
402
+ # Enabled: false
403
+ #
404
+ # Offense count: 1
405
+ # Cop supports --auto-correct.
406
+ Style/SpecialGlobalVars:
407
+ Exclude:
408
+ - 'ds.gemspec'
409
+
410
+ # Offense count: 309
411
+ # Cop supports --auto-correct.
412
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
413
+ # Style/StringLiterals:
414
+ # Enabled: false
415
+ #
416
+ # Offense count: 5
417
+ # Cop supports --auto-correct.
418
+ # Configuration parameters: IgnoredMethods.
419
+ # Style/SymbolProc:
420
+ # Exclude:
421
+ # - 'lib/ds/trees/tree.rb'
422
+ # - 'test/test_binary_tree.rb'
423
+ # - 'test/test_list.rb'
424
+ # - 'test/test_tree.rb'
425
+ #
426
+ # Offense count: 22
427
+ # Cop supports --auto-correct.
428
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
429
+ # Style/TrailingBlankLines:
430
+ # Enabled: false
431
+ #
432
+ # Offense count: 70
433
+ # Cop supports --auto-correct.
434
+ # Style/TrailingWhitespace:
435
+ # Enabled: false
436
+ #
437
+ # Offense count: 1
438
+ # Style/UnlessElse:
439
+ # Exclude:
440
+ # - 'lib/ds/trees/tree.rb'
441
+ #
442
+ # Offense count: 2
443
+ # Cop supports --auto-correct.
444
+ # Style/UnneededPercentQ:
445
+ # Exclude:
446
+ # - 'ds.gemspec'
447
+ #
448
+ # Offense count: 1
449
+ # Cop supports --auto-correct.
450
+ # Configuration parameters: WordRegex.
451
+ # Style/WordArray:
452
+ # MinSize: 4