44件ヒット
[1-44件を表示]
(0.016秒)
種類
- インスタンスメソッド (33)
- クラス (11)
クラス
- Enumerator (22)
-
Prime
:: EratosthenesGenerator (11)
検索結果
先頭4件
-
Enumerator
# rewind -> self (18155.0) -
列挙状態を巻き戻します。
...態を巻き戻します。
next メソッドによる外部列挙の状態を最初まで巻き戻します。 self を返します。
内包するオブジェクトが rewind メソッドを持つとき(respond_to?(:rewind) に
真を返すとき) は、その rewind メソッドを呼び出し......ます。
@see Enumerator#next
//emlist[例][ruby]{
str = "xyz"
enum = str.each_byte
p enum.next # => 120
p enum.next # => 121
enum.rewind
p enum.next # => 120
//}... -
Enumerator
# next -> object (18143.0) -
「次」のオブジェクトを返します。
...合は、
StopIteration 例外を発生します。このとき列挙状態は変化しません。
つまりもう一度 next を呼ぶと再び例外が発生します。
next メソッドによる外部列挙の状態は他のイテレータメソッドによる
内部列挙には影響を与え......しているとき
@see Enumerator#rewind
//emlist[例1][ruby]{
str = "xyz"
enum = str.each_byte
str.bytesize.times do
puts enum.next
end
# => 120
# 121
# 122
//}
//emlist[例2][ruby]{
str = "xyz"
enum = str.each_byte
begin
puts enum.next while true
rescue StopIteration
p......121
# 122
# iteration reached at end
puts enum.next
#=> 再度 StopIteration 例外が発生
//}
//emlist[例3: Kernel.#loop は StopIteration を捕捉します。][ruby]{
str = "xyz"
enum = str.each_byte
loop do
puts enum.next
end
# => 120
# 121
# 122
//}... -
Prime
:: EratosthenesGenerator # rewind -> nil (18131.0) -
列挙状態を巻き戻します。
...列挙状態を巻き戻します。
//emlist[例][ruby]{
require 'prime'
generator = Prime::EratosthenesGenerator.new
p generator.next #=> 2
p generator.next #=> 3
p generator.next #=> 5
generator.rewind
p generator.next #=> 2
//}... -
Prime
:: PseudoPrimeGenerator (12.0) -
擬似素数列の列挙子のための抽象クラスです。
...::PseudoPrimeGenerator のインスタンスであることが期待されています。
このクラスを継承する具象クラスは succ, next, rewind をオーバーライドしなければなりません。
独自の素数列挙アルゴリズムを実装しようとする場合を除い...