Prime::EratosthenesGenerator

class Prime::EratosthenesGenerator

Parent:
Prime::PseudoPrimeGenerator

An implementation of PseudoPrimeGenerator.

Uses EratosthenesSieve.

Public Class Methods

new() Show source
Calls superclass method Prime::PseudoPrimeGenerator.new
# File lib/prime.rb, line 307
def initialize
  @last_prime_index = -1
  super
end

Public Instance Methods

next()
Alias for: succ
rewind() Show source
# File lib/prime.rb, line 316
def rewind
  initialize
end
succ() Show source
# File lib/prime.rb, line 312
def succ
  @last_prime_index += 1
  EratosthenesSieve.instance.get_nth_prime(@last_prime_index)
end
Also aliased as: next

Ruby Core © 1993–2017 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部