181件ヒット
[101-181件を表示]
(0.124秒)
別のキーワード
モジュール
-
Net
:: HTTPHeader (36) - TSort (23)
キーワード
- [] (20)
-
each
_ strongly _ connected _ component _ from (23) -
fetch
_ values (22)
検索結果
先頭5件
-
Array
# fetch(nth) {|nth| . . . } -> object (24240.0) -
nth 番目の要素を返します。
...nth 番目の要素を返します。
Array#[] (nth) とは nth 番目の要素が存在しない場合の振舞いが異
なります。最初の形式では、例外 IndexError が発生します。
二番目の形式では、引数 ifnone を返します。
三番目の形式では、ブロッ......た結果を返します。
@param nth 取得したい要素のインデックスを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる
暗黙の型変換を試みます。
@param ifnone 要素が存在しなか......値を指定します。
@raise TypeError 引数 nth に整数以外の(暗黙の型変換が行えない)オブジェ
クトを指定した場合に発生します。
@raise IndexError 引数 ifnone もブロックも指定しておらず、 nth 番目の要
素... -
Array
# fetch(nth , ifnone) -> object (24240.0) -
nth 番目の要素を返します。
...nth 番目の要素を返します。
Array#[] (nth) とは nth 番目の要素が存在しない場合の振舞いが異
なります。最初の形式では、例外 IndexError が発生します。
二番目の形式では、引数 ifnone を返します。
三番目の形式では、ブロッ......た結果を返します。
@param nth 取得したい要素のインデックスを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる
暗黙の型変換を試みます。
@param ifnone 要素が存在しなか......値を指定します。
@raise TypeError 引数 nth に整数以外の(暗黙の型変換が行えない)オブジェ
クトを指定した場合に発生します。
@raise IndexError 引数 ifnone もブロックも指定しておらず、 nth 番目の要
素... -
Array
# fetch _ values(*indexes) -> Array (12245.0) -
引数で指定されたインデックスに対する値の配列を返します。
...ます。
@param indexes 取得したい要素のインデックスを指定します。
@raise IndexError ブロックが与えられてない時に、範囲外のインデックスを引数で指定すると発生します。
//emlist[例][ruby]{
ary = ["a", "b", "c"]
ary.fetch_values(0, 2) #......=> ["a", "c"]
ary.fetch_values(-1, 1) # => ["d", "b"]
ary.fetch_values(0, 10) # => index 10 outside of array bounds: -3...3 (IndexError)
ary.fetch_values(0, 10) { |i| i.to_s } # => ["a", "10"]
//}
@see Array#values_at, Array#fetch... -
Array
# fetch _ values(*indexes) { |index| . . . } -> Array (12245.0) -
引数で指定されたインデックスに対する値の配列を返します。
...ます。
@param indexes 取得したい要素のインデックスを指定します。
@raise IndexError ブロックが与えられてない時に、範囲外のインデックスを引数で指定すると発生します。
//emlist[例][ruby]{
ary = ["a", "b", "c"]
ary.fetch_values(0, 2) #......=> ["a", "c"]
ary.fetch_values(-1, 1) # => ["d", "b"]
ary.fetch_values(0, 10) # => index 10 outside of array bounds: -3...3 (IndexError)
ary.fetch_values(0, 10) { |i| i.to_s } # => ["a", "10"]
//}
@see Array#values_at, Array#fetch... -
Hash
# fetch _ values(key , . . . ) -> [object] (12239.0) -
引数で指定されたキーに関連づけられた値の配列を返します。
...)。
@param key 探索するキーを任意個指定します。
@raise KeyError ブロックが与えられてない時にキーの探索に失敗すると発生します。
//emlist[例][ruby]{
h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }
h.fetch_values("cow", "cat")......# => ["bovine", "feline"]
h.fetch_values("cow", "bird") # raises KeyError
h.fetch_values("cow", "bird") { |k| k.upcase } # => ["bovine", "BIRD"]
//}
@see Hash#values_at, Hash#fetch... -
Hash
# fetch _ values(key , . . . ) { |key| . . . } -> [object] (12239.0) -
引数で指定されたキーに関連づけられた値の配列を返します。
...)。
@param key 探索するキーを任意個指定します。
@raise KeyError ブロックが与えられてない時にキーの探索に失敗すると発生します。
//emlist[例][ruby]{
h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }
h.fetch_values("cow", "cat")......# => ["bovine", "feline"]
h.fetch_values("cow", "bird") # raises KeyError
h.fetch_values("cow", "bird") { |k| k.upcase } # => ["bovine", "BIRD"]
//}
@see Hash#values_at, Hash#fetch... -
TSort
# each _ strongly _ connected _ component _ from(node , id _ map={} , stack=[]) -> Enumerator (6119.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(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| . . . } -> () (6119.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(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... -
Thread
# [](name) -> object | nil (3131.0) -
name に対応したスレッドに固有のデータを取り出します。 name に対応するスレッド固有データがなければ nil を返し ます。
...@param name スレッド固有データのキーを文字列か Symbol で指定します。
//emlist[例][ruby]{
[
Thread.new { Thread.current["name"] = "A" },
Thread.new { Thread.current[:name] = "B" },
Thread.new { Thread.current["name"] = "C" }
].each do |th|
th.join
puts "#{th.ins......pect}: #{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を切り替える場合は動的スコープとしては... -
Hash
# [](key) -> object | nil (125.0) -
key に関連づけられた値を返します。
...Hash#fetch または Hash#key? を使ってください。
@param key 探索するキーを指定します。
//emlist[例][ruby]{
h = {:ab => "some" , :cd => "all"}
p h[:ab] #=> "some"
p h[:ef] #=> nil
h1 = Hash.new("default value")
p h1[:non] #=> "default val......ue"
h2 = Hash.new {|*arg| arg}
p h2[:non] #=> [{}, :non]
//}
@see Hash.new, Hash#fetch,Hash#values_at,Hash#key?, Hash#default, Hash#default_proc...