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. |
#size, | |
#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 327
def initialize @index = -1 super end
Instance Method Details
#next
Alias for #succ.
# File 'lib/prime.rb', line 338
alias next succ
#rewind
[ GitHub ]# File 'lib/prime.rb', line 335
def rewind initialize end
#succ Also known as: #next
[ GitHub ]# File 'lib/prime.rb', line 332
def succ TrialDivision.instance[@index += 1] end