種類
- インスタンスメソッド (105)
- ライブラリ (24)
- 特異メソッド (24)
クラス
- Hash (12)
モジュール
- TSort (93)
オブジェクト
- ENV (24)
キーワード
-
each
_ strongly _ connected _ component (23) -
each
_ strongly _ connected _ component _ from (23) - invert (12)
-
strongly
_ connected _ components (12) - tsort (24)
-
tsort
_ each (23) -
win32
/ registry (12)
検索結果
先頭5件
-
ENV
. each _ key -> Enumerator (18114.0) -
key を引数としてブロックを評価します。
...key を引数としてブロックを評価します。
//emlist[][ruby]{
ENV['FOO'] = 'bar'
ENV.each_key do |key|
p "key #{key} detected" if key == 'FOO'
end
# "key FOO detected"
//}... -
ENV
. each _ key {|key| . . . } -> self (18114.0) -
key を引数としてブロックを評価します。
...key を引数としてブロックを評価します。
//emlist[][ruby]{
ENV['FOO'] = 'bar'
ENV.each_key do |key|
p "key #{key} detected" if key == 'FOO'
end
# "key FOO detected"
//}... -
tsort (78.0)
-
tsort はトポロジカルソートと強連結成分に関するモジュールを提供します。
...す。
=== Example
//emlist[][ruby]{
require 'tsort'
class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(node, &block)
fetch(node).each(&block)
end
end
{1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort
#=> [3, 2, 1, 4]
{1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_conne......tsort'
class Make
def initialize
@dep = {}
@dep.default = []
end
def rule(outputs, inputs=[], &block)
triple = [outputs, inputs, block]
outputs.each {|f| @dep[f] = [triple]}
@dep[triple] = inputs
end
def build(target)
each_strongly_connected_component_from(target......) {|ns|
if ns.length != 1
fs = ns.delete_if {|n| Array === n}
raise TSort::Cyclic.new("cyclic dependencies: #{fs.join ', '}")
end
n = ns.first
if Array === n
outputs, inputs, block = n
inputs_time = inputs.map {|f| File.mtime f}.max
beg... -
Hash
# invert -> Hash (18.0) -
値からキーへのハッシュを作成して返します。
...備えて、変換後の値を配列として保持するには、次のようにします。
//emlist[][ruby]{
def safe_invert(orig_hash)
orig_hash.each_key.group_by do |key|
orig_hash[key]
end
end
p safe_invert({"a"=>1, "b"=>1, "c"=>3}) # => {1=>["a", "b"], 3=>["c"]}
//}
@see Hash#key... -
TSort
# each _ strongly _ connected _ component -> Enumerator (18.0) -
TSort#strongly_connected_components メソッドのイテレータ版です。 obj.each_strongly_connected_component は obj.strongly_connected_components.each に似ていますが、 ブロックの評価中に obj が変更された場合は予期しない結果になる ことがあります。
...します。
//emlist[使用例][ruby]{
require '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 nod... -
TSort
# each _ strongly _ connected _ component {|nodes| . . . } -> nil (18.0) -
TSort#strongly_connected_components メソッドのイテレータ版です。 obj.each_strongly_connected_component は obj.strongly_connected_components.each に似ていますが、 ブロックの評価中に obj が変更された場合は予期しない結果になる ことがあります。
...します。
//emlist[使用例][ruby]{
require '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 nod... -
TSort
# each _ strongly _ connected _ component _ from(node , id _ map={} , stack=[]) -> Enumerator (18.0) -
node から到達可能な強連結成分についてのイテレータです。
...能なノードを表示する][ruby]{
require '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... -
TSort
# each _ strongly _ connected _ component _ from(node , id _ map={} , stack=[]) {|nodes| . . . } -> () (18.0) -
node から到達可能な強連結成分についてのイテレータです。
...能なノードを表示する][ruby]{
require '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... -
TSort
# strongly _ connected _ components -> Array (18.0) -
強連結成分の集まりを配列の配列として返します。 この配列は子から親に向かってソートされています。 各要素は強連結成分を表す配列です。
...列です。
//emlist[使用例][ruby]{
require '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=>[]}
p non_sort.strongly_connected_components
#=> [[4], [2, 3],...