るりまサーチ

最速Rubyリファレンスマニュアル検索!
31件ヒット [1-31件を表示] (0.189秒)

別のキーワード

  1. fiddle ruby_free
  2. rbconfig ruby
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

モジュール

検索結果

Thread#[](name) -> object | nil (24243.0)

name に対応したスレッドに固有のデータを取り出します。 name に対応するスレッド固有データがなければ nil を返し ます。

...aram name スレッド固有データのキーを文字列か Symbol で指定します。

//emlist[例][ruby]{
[
T
hread.new { Thread.current["name"] = "A" },
T
hread.new { Thread.current[:name] = "B" },
T
hread.new { Thread.current["name"] = "C" }
].each do |th|
t
h.join
puts "#{th.inspect...
...}: #{th[:name]}"
end

# => #<Thread:0x00000002a54220 dead>: A
# => #<Thread:0x00000002a541a8 dead>: B
# => #<Thread:0x00000002a54130 dead>: C
//}

T
hread#[] Thread#[]= を用いたスレッド固有の変数は
Fiber を切り替えると異なる変数を返す事に注意してください。...
...//emlist[][ruby]{
def meth(newvalue)
begin
oldvalue = Thread.current[:name]
T
hread.current[:name] = newvalue
yield
ensure
T
hread.current[:name] = oldvalue
end
end
//}

この関数に与えるブロックがFiberを切り替える場合は動的スコープとしては
正し...

TSort#each_strongly_connected_component_from(node, id_map={}, stack=[]) -> Enumerator (15419.0)

node から到達可能な強連結成分についてのイテレータです。

...ん。

each_strongly_connected_component_from は
t
sort_each_node を呼びません。

@param node ノードを指定します。

//emlist[例 到達可能なノードを表示する][ruby]{
r
equire 'tsort'

class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(node,...
...&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| ...} -> () (15419.0)

node から到達可能な強連結成分についてのイテレータです。

...ん。

each_strongly_connected_component_from は
t
sort_each_node を呼びません。

@param node ノードを指定します。

//emlist[例 到達可能なノードを表示する][ruby]{
r
equire 'tsort'

class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(node,...
...&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...