別のキーワード
クラス
- Array (21)
- Enumerator (24)
- Set (12)
- String (36)
- Thread (48)
- Vector (24)
-
WIN32OLE
_ TYPE (12) -
WIN32OLE
_ VARIABLE (12)
モジュール
- Enumerable (24)
- TSort (23)
キーワード
-
default
_ event _ sources (12) - each2 (24)
-
each
_ line (24) -
each
_ strongly _ connected _ component _ from (23) - first (24)
- join (24)
-
next
_ values (12) -
ole
_ type _ detail (12) - pack (21)
-
peek
_ values (12) - unpack (12)
- value (12)
検索結果
先頭5件
-
Set
# each {|o| . . . } -> self (18114.0) -
集合の各要素についてブロックを実行します。
...集合の各要素についてブロックを実行します。
//emlist[][ruby]{
require 'set'
s = Set[10, 20]
ary = []
s.each {|num| ary << num + 1}
p ary # => [11, 21]
//}......集合の各要素についてブロックを実行します。
//emlist[][ruby]{
s = Set[10, 20]
ary = []
s.each {|num| ary << num + 1}
p ary # => [11, 21]
//}... -
Thread
# [](name) -> object | nil (18107.0) -
name に対応したスレッドに固有のデータを取り出します。 name に対応するスレッド固有データがなければ nil を返し ます。
...ead.new { Thread.current["name"] = "C" }
].each do |th|
th.join
puts "#{th.inspect}: #{th[:name]}"
end
# => #<Thread:0x00000002a54220 dead>: A
# => #<Thread:0x00000002a541a8 dead>: B
# => #<Thread:0x00000002a54130 dead>: C
//}
Thread#[] と Thread#[]= を用いたスレッド固有の変数......は
Fiber を切り替えると異なる変数を返す事に注意してください。
//emlist[][ruby]{
def meth(newvalue)
begin
oldvalue = Thread.current[:name]
Thread.current[:name] = newvalue
yield
ensure
Thread.current[:name] = oldvalue
end
end
//}
この関数に与......えるブロックがFiberを切り替える場合は動的スコープとしては
正しく動作しません。
//emlist[][ruby]{
f = Fiber.new {
meth(1) {
Fiber.yield
}
}
meth(2) {
f.resume
}
f.resume
p Thread.current[:name]
# => nil if fiber-local
# => 2 if thread-local (The value 2... -
TSort
# each _ strongly _ connected _ component _ from(node , id _ map={} , stack=[]) -> Enumerator (6263.0) -
node から到達可能な強連結成分についてのイテレータです。
...せん。
each_strongly_connected_component_from は
tsort_each_node を呼びません。
@param node ノードを指定します。
//emlist[例 到達可能なノードを表示する][ruby]{
require 'tsort'
class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(no......de, &block)
fetch(node).each(&block)
end
end
non_sort = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
non_sort.each_strongly_connected_component{|nodes|
p nodes
nodes.each {|node|
non_sort.each_strongly_connected_component_from(node){|ns|
printf("%s -> %s\n", node, ns.join(","))
}
}......}
#出力
#=> [4]
#=> 4 -> 4
#=> [2, 3]
#=> 2 -> 4
#=> 2 -> 2,3
#=> 3 -> 4
#=> 3 -> 3,2
#=> [1]
#=> 1 -> 4
#=> 1 -> 2,3
#=> 1 -> 1
//}
@see TSort.each_strongly_connected_component_from... -
TSort
# each _ strongly _ connected _ component _ from(node , id _ map={} , stack=[]) {|nodes| . . . } -> () (6263.0) -
node から到達可能な強連結成分についてのイテレータです。
...せん。
each_strongly_connected_component_from は
tsort_each_node を呼びません。
@param node ノードを指定します。
//emlist[例 到達可能なノードを表示する][ruby]{
require 'tsort'
class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(no......de, &block)
fetch(node).each(&block)
end
end
non_sort = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
non_sort.each_strongly_connected_component{|nodes|
p nodes
nodes.each {|node|
non_sort.each_strongly_connected_component_from(node){|ns|
printf("%s -> %s\n", node, ns.join(","))
}
}......}
#出力
#=> [4]
#=> 4 -> 4
#=> [2, 3]
#=> 2 -> 4
#=> 2 -> 2,3
#=> 3 -> 4
#=> 3 -> 3,2
#=> [1]
#=> 1 -> 4
#=> 1 -> 2,3
#=> 1 -> 1
//}
@see TSort.each_strongly_connected_component_from... -
String
# each _ line(rs = $ / ) -> Enumerator (6115.0) -
文字列中の各行に対して繰り返します。 行の区切りは rs に指定した文字列で、 そのデフォルト値は変数 $/ の値です。 各 line には区切りの文字列も含みます。
...//emlist[例][ruby]{
"aa\nbb\ncc\n".each_line do |line|
p line
end
# => "aa\n"
# => "bb\n"
# => "cc\n"
p "aa\nbb\ncc\n".lines.to_a # => ["aa\n", "bb\n", "cc\n"]
p "aa\n".lines.to_a # => ["aa\n"]
p "".lines.to_a # => []
s = "aa\nbb\ncc\n"
p s.lines("\n").to... -
String
# each _ line(rs = $ / ) {|line| . . . } -> self (6115.0) -
文字列中の各行に対して繰り返します。 行の区切りは rs に指定した文字列で、 そのデフォルト値は変数 $/ の値です。 各 line には区切りの文字列も含みます。
...//emlist[例][ruby]{
"aa\nbb\ncc\n".each_line do |line|
p line
end
# => "aa\n"
# => "bb\n"
# => "cc\n"
p "aa\nbb\ncc\n".lines.to_a # => ["aa\n", "bb\n", "cc\n"]
p "aa\n".lines.to_a # => ["aa\n"]
p "".lines.to_a # => []
s = "aa\nbb\ncc\n"
p s.lines("\n").to... -
String
# each _ line(rs = $ / , chomp: false) -> Enumerator (6115.0) -
文字列中の各行に対して繰り返します。 行の区切りは rs に指定した文字列で、 そのデフォルト値は変数 $/ の値です。 各 line には区切りの文字列も含みます。
...//emlist[例][ruby]{
"aa\nbb\ncc\n".each_line do |line|
p line
end
# => "aa\n"
# => "bb\n"
# => "cc\n"
p "aa\nbb\ncc\n".lines.to_a # => ["aa\n", "bb\n", "cc\n"]
p "aa\n".lines.to_a # => ["aa\n"]
p "".lines.to_a # => []
s = "aa\nbb\ncc\n"
p s.lines("\n").to... -
String
# each _ line(rs = $ / , chomp: false) {|line| . . . } -> self (6115.0) -
文字列中の各行に対して繰り返します。 行の区切りは rs に指定した文字列で、 そのデフォルト値は変数 $/ の値です。 各 line には区切りの文字列も含みます。
...//emlist[例][ruby]{
"aa\nbb\ncc\n".each_line do |line|
p line
end
# => "aa\n"
# => "bb\n"
# => "cc\n"
p "aa\nbb\ncc\n".lines.to_a # => ["aa\n", "bb\n", "cc\n"]
p "aa\n".lines.to_a # => ["aa\n"]
p "".lines.to_a # => []
s = "aa\nbb\ncc\n"
p s.lines("\n").to... -
Vector
# each2(v) -> Enumerator (6109.0) -
ベクトルの各要素と、それに対応するインデックスを持つ引数 v の要素との組に対して (2引数の) ブロックを繰返し評価します。
...スを持つ引数 v の要素との組に対して (2引数の) ブロックを繰返し評価します。
v は配列互換(size メソッドと [] メソッドを持つ)オブジェクトです。
Vector も使えます。
ブロックを省略した場合は Enumerator を返します。
@par... -
Vector
# each2(v) {|x , y| . . . } -> self (6109.0) -
ベクトルの各要素と、それに対応するインデックスを持つ引数 v の要素との組に対して (2引数の) ブロックを繰返し評価します。
...スを持つ引数 v の要素との組に対して (2引数の) ブロックを繰返し評価します。
v は配列互換(size メソッドと [] メソッドを持つ)オブジェクトです。
Vector も使えます。
ブロックを省略した場合は Enumerator を返します。
@par... -
Array
# pack(template) -> String (19.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
...ist[][ruby]{
["abc"].pack("a") # => "a"
["abc"].pack("a*") # => "abc"
["abc"].pack("a4") # => "abc\x00"
"abc\0".unpack("a4") # => ["abc\x00"]
"abc ".unpack("a4") # => ["abc "]
//}
: A
ASCII文字列(スペースを詰める/後続するヌル文字やスペースを削除)
//emlist[][ru....../emlist[][ruby]{
["abc"].pack("Z") # => "a"
["abc"].pack("Z*") # => "abc\x00"
["abc"].pack("Z5") # => "abc\x00\x00"
"abc\0".unpack("Z4") # => ["abc"]
"abc ".unpack("Z4") # => ["abc "]
//}
: b
ビットストリング(各バイトごとに下位ビットから上位ビット)
//emlist[][ruby]{......000000001000000"].pack("b*") # => "\x01\x02"
//}
: B
ビットストリング(各バイトごとに上位ビットから下位ビット)
//emlist[][ruby]{
"\xFF\x00".unpack("B*") # => ["1111111100000000"]
"\x01\x02".unpack("B*") # => ["0000000100000010"]
"\x01\x02".unpack("B9") # => ["0000000...