ライブラリ
- ビルトイン (55)
-
net
/ http (22) - tsort (74)
-
win32
/ registry (11)
クラス
- Hash (55)
-
Win32
:: Registry (11)
モジュール
-
Net
:: HTTPHeader (22) - TSort (74)
キーワード
- each (11)
-
each
_ name (11) -
each
_ pair (11) -
each
_ strongly _ connected _ component (21) -
each
_ strongly _ connected _ component _ from (21) -
each
_ value (11) - invert (11)
-
strongly
_ connected _ components (11) -
tsort
_ each (21)
検索結果
先頭5件
-
Net
:: HTTPHeader # each _ key {|name| . . . } -> () (27302.0) -
保持しているヘッダ名をブロックに渡して呼びだします。
...呼びだします。
ヘッダ名は小文字で統一されます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_name { |name| puts name }
# => accept-encoding
# => accept
# => user-agent
//}... -
Win32
:: Registry # each _ key {|subkey , wtime| . . . } (27202.0) -
@todo
...@todo
キーのサブキーを列挙します。
subkey はサブキーの名前を表す String です。
wtime は最終更新時刻を表す FILETIME (64-bit 整数) です。
(⇒Win32::Registry.wtime2time)... -
Hash
# each _ key -> Enumerator (24345.0) -
ハッシュのキーを引数としてブロックを評価します。
...れた順です。
ブロック付きの場合selfを、
無しで呼ばれた場合Enumeratorを返します。
//emlist[例][ruby]{
{:a=>1, :b=>2}.each_key {|k| p k}
#=> :a
# :b
p({:a=>1, :b=>2}.each_key) # => #<Enumerator: {:a=>1, :b=>2}:each_key>
//}
@see Hash#each_pair,Hash#each_value... -
Net
:: HTTPHeader # each _ name {|name| . . . } -> () (15302.0) -
保持しているヘッダ名をブロックに渡して呼びだします。
...呼びだします。
ヘッダ名は小文字で統一されます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_name { |name| puts name }
# => accept-encoding
# => accept
# => user-agent
//}... -
TSort
# each _ strongly _ connected _ component _ from(node , id _ map={} , stack=[]) -> Enumerator (12313.0) -
node から到達可能な強連結成分についてのイテレータです。
...
node から到達可能な強連結成分についてのイテレータです。
返す値は規定されていません。
each_strongly_connected_component_from は
tsort_each_node を呼びません。
@param node ノードを指定します。
//emlist[例 到達可能なノードを表示......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_connec......ted_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| . . . } -> () (12313.0) -
node から到達可能な強連結成分についてのイテレータです。
...
node から到達可能な強連結成分についてのイテレータです。
返す値は規定されていません。
each_strongly_connected_component_from は
tsort_each_node を呼びません。
@param node ノードを指定します。
//emlist[例 到達可能なノードを表示......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_connec......ted_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 -> Enumerator (12207.0) -
TSort#strongly_connected_components メソッドのイテレータ版です。 obj.each_strongly_connected_component は obj.strongly_connected_components.each に似ていますが、 ブロックの評価中に obj が変更された場合は予期しない結果になる ことがあります。
...strongly_connected_components メソッドのイテレータ版です。
obj.each_strongly_connected_component は
obj.strongly_connected_components.each に似ていますが、
ブロックの評価中に obj が変更された場合は予期しない結果になる
ことがあります。
each_......ngly_connected_component は nil を返します。
//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_stron......gly_connected_component{|nodes|
p nodes
}
#出力
#=> [4]
#=> [2, 3]
#=> [1]
//}
@see TSort.each_strongly_connected_component... -
TSort
# each _ strongly _ connected _ component {|nodes| . . . } -> nil (12207.0) -
TSort#strongly_connected_components メソッドのイテレータ版です。 obj.each_strongly_connected_component は obj.strongly_connected_components.each に似ていますが、 ブロックの評価中に obj が変更された場合は予期しない結果になる ことがあります。
...strongly_connected_components メソッドのイテレータ版です。
obj.each_strongly_connected_component は
obj.strongly_connected_components.each に似ていますが、
ブロックの評価中に obj が変更された場合は予期しない結果になる
ことがあります。
each_......ngly_connected_component は nil を返します。
//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_stron......gly_connected_component{|nodes|
p nodes
}
#出力
#=> [4]
#=> [2, 3]
#=> [1]
//}
@see TSort.each_strongly_connected_component... -
Hash
# invert -> Hash (9231.0) -
値からキーへのハッシュを作成して返します。
..."a" => 0, "b" => 100, "c" => 200, "d" => 300, "e" => 300 }
p h.invert #=> {0=>"a", 100=>"b", 200=>"c", 300=>"e"}
//}
=== 参考
値が重複していたときに備えて、変換後の値を配列として保持するには、次のようにします。
//emlist[][ruby]{
def safe_invert(orig_ha......sh)
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... -
Hash
# each -> Enumerator (6255.0) -
ハッシュのキーと値を引数としてブロックを評価します。
...合 Enumerator を返します。
each_pair は each のエイリアスです。
//emlist[例][ruby]{
{:a=>1, :b=>2}.each {|a| p a}
#=> [:a, 1]
# [:b, 2]
{:a=>1, :b=>2}.each {|k, v| p [k, v]}
#=> [:a, 1]
# [:b, 2]
p({:a=>1, :b=>2}.each_pair) # => #<Enumerator: {:a=>1, :b=>2}:each_pair>
//}......@see Hash#each_key,Hash#each_value...