Class: Prime::TrialDivisionGenerator
- Inherits:
-
PseudoPrimeGenerator
- Object
- PseudoPrimeGenerator
- Prime::TrialDivisionGenerator
- Defined in:
- lib/backports/1.9.1/stdlib/prime.rb
Overview
An implementation of PseudoPrimeGenerator
which uses a prime table generated by trial division.
Instance Method Summary collapse
-
#initialize ⇒ TrialDivisionGenerator
constructor
A new instance of TrialDivisionGenerator.
- #rewind ⇒ Object
- #succ ⇒ Object (also: #next)
Methods inherited from PseudoPrimeGenerator
#each, #size, #upper_bound, #upper_bound=, #with_index, #with_object
Methods included from Enumerable
#all_with_pattern?, #any_with_pattern?, #chain, #chunk, #chunk_while, #compact, #count, #cycle, #drop, #drop_while, #each_entry, #each_with_index_with_optional_args_and_block, #each_with_object, #entries_with_optional_arguments, #filter_map, #find_index, #first, #flat_map, #grep_v, #group_by, #inject_with_symbol, #lazy, #max_by, #min_by, #minmax, #minmax_by, #none?, #none_with_pattern?, #one?, #one_with_pattern?, #reverse_each, #slice_after, #slice_before, #slice_when, #sum, #take, #take_while, #tally, #tally_with_hash_argument, #to_a_with_optional_arguments, #to_h, #to_h_with_block, #uniq
Constructor Details
#initialize ⇒ TrialDivisionGenerator
Returns a new instance of TrialDivisionGenerator.
327 328 329 330 |
# File 'lib/backports/1.9.1/stdlib/prime.rb', line 327 def initialize @index = -1 super end |
Instance Method Details
#rewind ⇒ Object
335 336 337 |
# File 'lib/backports/1.9.1/stdlib/prime.rb', line 335 def rewind initialize end |
#succ ⇒ Object Also known as: next
332 333 334 |
# File 'lib/backports/1.9.1/stdlib/prime.rb', line 332 def succ TrialDivision.instance[@index += 1] end |