Class: Prime::TrialDivisionGenerator
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
PseudoPrimeGenerator
|
|
Instance Chain:
self,
PseudoPrimeGenerator,
Enumerable
|
|
Inherits: |
Prime::PseudoPrimeGenerator
|
Defined in: | lib/prime.rb |
Overview
An implementation of PseudoPrimeGenerator which uses a prime table generated by trial division.
Class Method Summary
Instance Attribute Summary
PseudoPrimeGenerator - Inherited
Instance Method Summary
PseudoPrimeGenerator - Inherited
#each | Iterates the given block for each prime number. |
#next | alias of #succ. |
#rewind | Rewinds the internal position for enumeration. |
#succ | returns the next pseudo-prime number, and move the internal position forward. |
#with_index | see |
#with_object | see |
Constructor Details
.new ⇒ TrialDivisionGenerator
# File 'lib/prime.rb', line 325
def initialize @index = -1 super end
Instance Method Details
#next
Alias for #succ.
# File 'lib/prime.rb', line 336
alias next succ
#rewind
[ GitHub ]# File 'lib/prime.rb', line 333
def rewind initialize end
#succ Also known as: #next
[ GitHub ]# File 'lib/prime.rb', line 330
def succ TrialDivision.instance[@index += 1] end