huge_enumerable 0.1.0 → 0.1.1
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/lib/huge_enumerable/version.rb +1 -1
- data/lib/huge_enumerable.rb +31 -19
- metadata +10 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a31b89b4c2cdd80273c579549e27b093fa1723f737dcb5dcf67c8609a930ebc9
         | 
| 4 | 
            +
              data.tar.gz: 8de5ac7d85dd81a51349b763768e3d44dba188590c61802b6fb1d8182a5894c2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 06d6d73e2c3c2218f0b820a64ee9ee8714cfbdff0350fefcb061b9f965692eab828ec38a1dc159d6b7c38027cb40475525e47491a4adad4dd1770a93919935e6
         | 
| 7 | 
            +
              data.tar.gz: 4a1e0cbde30ab90bf71c9da8a1d3a180062205ec37e85c21bddbd594401d62ed68c15f4aecb570c60bd5ec385ff14ce0f1ad570adb4b810eb524228c665b4119
         | 
    
        data/lib/huge_enumerable.rb
    CHANGED
    
    | @@ -106,11 +106,13 @@ class HugeEnumerable | |
| 106 106 | 
             
              # If no block is given, an HugeCombination is returned instead.
         | 
| 107 107 | 
             
              # === Caveat
         | 
| 108 108 | 
             
              # max_array_size is currently inherited by the generated HugeCombination. This may change in the future.
         | 
| 109 | 
            -
              def combination(n) # :yields: element
         | 
| 110 | 
            -
                 | 
| 111 | 
            -
                 | 
| 112 | 
            -
                 | 
| 113 | 
            -
             | 
| 109 | 
            +
              def combination(n, &block) # :yields: element
         | 
| 110 | 
            +
                # Check to see if we have a specific random number generator to use.
         | 
| 111 | 
            +
                # Using hash comparison as dups, clones, and other actions can make == and eql? return false when it is actually the same method
         | 
| 112 | 
            +
                random_number_generator = rng.hash != method(:rand).hash ? rng : nil
         | 
| 113 | 
            +
                combo = HugeCombination.new(self.clone.reset!, n, max_array_size, random_number_generator)
         | 
| 114 | 
            +
                if block
         | 
| 115 | 
            +
                  combo.each(&block)
         | 
| 114 116 | 
             
                  self
         | 
| 115 117 | 
             
                else
         | 
| 116 118 | 
             
                  combo
         | 
| @@ -118,9 +120,15 @@ class HugeEnumerable | |
| 118 120 | 
             
              end
         | 
| 119 121 |  | 
| 120 122 | 
             
              # Calls the given block once for each element in the next array of the collection, passing that element as a parameter.
         | 
| 121 | 
            -
              def each # :yields: element
         | 
| 123 | 
            +
              def each(&block) # :yields: element
         | 
| 122 124 | 
             
                # TODO: Return an Enumerator if no block is given
         | 
| 123 | 
            -
                remaining_or(max_array_size).times  | 
| 125 | 
            +
                remaining_or(max_array_size).times(&(block << method(:_fetch)))
         | 
| 126 | 
            +
                # remaining_or(max_array_size).times { |i| yield _fetch(i) }
         | 
| 127 | 
            +
              end
         | 
| 128 | 
            +
             | 
| 129 | 
            +
              def initialize_copy(orig)
         | 
| 130 | 
            +
                super
         | 
| 131 | 
            +
                @rng = @rng.unbind.bind(self) if @rng.respond_to?(:unbind) # Make sure this is bound to self if it is a method
         | 
| 124 132 | 
             
              end
         | 
| 125 133 |  | 
| 126 134 | 
             
              def max_array_size #:nodoc:
         | 
| @@ -142,11 +150,13 @@ class HugeEnumerable | |
| 142 150 | 
             
              # If no block is given, a HugePermutation is returned instead.
         | 
| 143 151 | 
             
              # === Caveat
         | 
| 144 152 | 
             
              # max_array_size is currently inherited by the generated HugePermutation. This may change in the future.
         | 
| 145 | 
            -
              def permutation(n) # :yields: element
         | 
| 146 | 
            -
                 | 
| 147 | 
            -
                 | 
| 148 | 
            -
                 | 
| 149 | 
            -
             | 
| 153 | 
            +
              def permutation(n, &block) # :yields: element
         | 
| 154 | 
            +
                # Check to see if we have a specific random number generator to use.
         | 
| 155 | 
            +
                # Using hash comparison as dups, clones, and other actions can make == and eql? return false when it is actually the same method
         | 
| 156 | 
            +
                random_number_generator = rng.hash != method(:rand).hash ? rng : nil
         | 
| 157 | 
            +
                perm = HugePermutation.new(self.clone.reset!, n, max_array_size, random_number_generator)
         | 
| 158 | 
            +
                if block
         | 
| 159 | 
            +
                  perm.each(&block)
         | 
| 150 160 | 
             
                  self
         | 
| 151 161 | 
             
                else
         | 
| 152 162 | 
             
                  perm
         | 
| @@ -165,12 +175,14 @@ class HugeEnumerable | |
| 165 175 | 
             
              # === Caveat
         | 
| 166 176 | 
             
              # max_array_size is currently inherited by the generated HugeProduct. This may change in the future.
         | 
| 167 177 | 
             
              # other_enumerable is duped and reset if it is a HugeEnumerable. This may change in the future.
         | 
| 168 | 
            -
              def product(other_enumerable) # :yields: element
         | 
| 169 | 
            -
                other_enumerable = other_enumerable. | 
| 170 | 
            -
                 | 
| 171 | 
            -
                 | 
| 172 | 
            -
                 | 
| 173 | 
            -
             | 
| 178 | 
            +
              def product(other_enumerable, &block) # :yields: element
         | 
| 179 | 
            +
                other_enumerable = other_enumerable.clone.reset! if other_enumerable.is_a?(HugeEnumerable)
         | 
| 180 | 
            +
                # Check to see if we have a specific random number generator to use.
         | 
| 181 | 
            +
                # Using hash comparison as dups, clones, and other actions can make == and eql? return false when it is actually the same method
         | 
| 182 | 
            +
                random_number_generator = rng.hash != method(:rand).hash ? rng : nil
         | 
| 183 | 
            +
                prod = HugeProduct.new(self.clone.reset!, other_enumerable, max_array_size, random_number_generator)
         | 
| 184 | 
            +
                if block
         | 
| 185 | 
            +
                  prod.each(&block)
         | 
| 174 186 | 
             
                  self
         | 
| 175 187 | 
             
                else
         | 
| 176 188 | 
             
                  prod
         | 
| @@ -221,7 +233,7 @@ class HugeEnumerable | |
| 221 233 | 
             
              # ==== Side Effects
         | 
| 222 234 | 
             
              # The new collection is reset to the current collection's original size and elements before shuffling.
         | 
| 223 235 | 
             
              def shuffle(rng=nil)
         | 
| 224 | 
            -
                self. | 
| 236 | 
            +
                self.clone.shuffle!(rng)
         | 
| 225 237 | 
             
              end
         | 
| 226 238 |  | 
| 227 239 | 
             
              # Randomly reorders the elements of the collection.
         | 
    
        metadata
    CHANGED
    
    | @@ -1,19 +1,22 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: huge_enumerable
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Frank Hall
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2024-06-20 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: prime_miller_rabin
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '0.1'
         | 
| 17 20 | 
             
                - - ">="
         | 
| 18 21 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 22 | 
             
                    version: 0.1.0
         | 
| @@ -21,6 +24,9 @@ dependencies: | |
| 21 24 | 
             
              prerelease: false
         | 
| 22 25 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 26 | 
             
                requirements:
         | 
| 27 | 
            +
                - - "~>"
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: '0.1'
         | 
| 24 30 | 
             
                - - ">="
         | 
| 25 31 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 32 | 
             
                    version: 0.1.0
         | 
| @@ -103,7 +109,7 @@ licenses: | |
| 103 109 | 
             
            - MIT
         | 
| 104 110 | 
             
            metadata:
         | 
| 105 111 | 
             
              homepage_uri: https://github.com/ChapterHouse/huge_enumerable
         | 
| 106 | 
            -
              source_code_uri: https://github.com/ChapterHouse/huge_enumerable/tree/v0.1. | 
| 112 | 
            +
              source_code_uri: https://github.com/ChapterHouse/huge_enumerable/tree/v0.1.1
         | 
| 107 113 | 
             
            post_install_message:
         | 
| 108 114 | 
             
            rdoc_options: []
         | 
| 109 115 | 
             
            require_paths:
         | 
| @@ -119,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 119 125 | 
             
                - !ruby/object:Gem::Version
         | 
| 120 126 | 
             
                  version: '0'
         | 
| 121 127 | 
             
            requirements: []
         | 
| 122 | 
            -
            rubygems_version: 3.2. | 
| 128 | 
            +
            rubygems_version: 3.2.33
         | 
| 123 129 | 
             
            signing_key:
         | 
| 124 130 | 
             
            specification_version: 4
         | 
| 125 131 | 
             
            summary: Enumerate, sample, shuffle, combine, permutate, and create products of massive
         |