xenum 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a22147054180684998dfbea79223da8a588abf7e0f923e3a1189b76a52d4335e
4
- data.tar.gz: bd0b21403fa4d114cbb5139f1c514226648f8de71406da76b6bfb086375346fb
3
+ metadata.gz: 6702efc29813e62dabd6f74d9c7bc8067b191a79f3b416f6a1336ba20e6497d4
4
+ data.tar.gz: 94676ca2107d67c7680d2e6b963e67c5e19f7ab8386c9808e96c751dcafe34ee
5
5
  SHA512:
6
- metadata.gz: 94efb08dd1112f2bd67b3380b2e104d48392ff0467f39b28e9830b686de9778d5956a43db1f353b31b371e77585ea836a260b9951c89d5ba91d705ad0617f6e4
7
- data.tar.gz: fdbaafde2073b72fbb450dcab5a134d7002cdefab5a89428a3977caaee0aac7eaaf1ef5dd9e6cf4ae82417032ddcc723931579f7a271507ab326634e88fb7329
6
+ metadata.gz: f82eac1237b52b16d7950bcaee008811a71ad905e966141893a13a51d04aa8ea9590d47590099f2eb204ec5d2df1a3b75a26db1e3ad5d0a6c159c56bf84776f2
7
+ data.tar.gz: 71df4dec9373651f55a6b5f9abbd4b74f0778b6be2726de4a69735886c0b5528c4e47a46f9d65fb7119b4c3ffa0ee655ce26b092273dfd1ec4b9eedb2bd23b81
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xenum (0.1.1)
4
+ xenum (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -67,4 +67,8 @@ e.take(5)
67
67
 
68
68
  [(6..8), [3,4,5], 3.times].reduce(&:merge_sort).to_a
69
69
  # [0, 1, 2, 3, 4, 5, 6, 7, 8]
70
+
71
+ # same result but faster
72
+ (6..8).merge_sort([3,4,5], 3.times).to_a
73
+ # [0, 1, 2, 3, 4, 5, 6, 7, 8]
70
74
  ```
data/lib/xenum/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Xenum
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/xenum.rb CHANGED
@@ -55,7 +55,24 @@ module Enumerable
55
55
  end
56
56
  end
57
57
 
58
- def merge_sort(that)
58
+ def merge_sort(*enums)
59
+ case enums.size
60
+ when 0
61
+ self
62
+ when 1
63
+ _merge_sort(enums[0])
64
+ else
65
+ enums2 = enums.pop((enums.size / 2) - 1)
66
+ enum2 = enums.pop
67
+ e2 = enum2.merge_sort(*enums2)
68
+ e1 = merge_sort(*enums)
69
+ e1.merge_sort(e2)
70
+ end
71
+ end
72
+
73
+ private
74
+
75
+ def _merge_sort(that)
59
76
  this = Enumerator === self ? self : self.to_enum
60
77
  that = Enumerator === that ? that : that.to_enum
61
78
 
@@ -103,8 +120,6 @@ module Enumerable
103
120
  end
104
121
  end
105
122
 
106
- private
107
-
108
123
  def lazy_insert_neg(index, objs)
109
124
  these = Enumerator === self ? self : self.to_enum
110
125
  queue = []
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xenum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-18 00:00:00.000000000 Z
11
+ date: 2024-03-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: