127件ヒット
[1-100件を表示]
(0.040秒)
別のキーワード
種類
- インスタンスメソッド (79)
- 特異メソッド (24)
- 文書 (12)
- ライブラリ (12)
クラス
- Hash (36)
-
Net
:: IMAP :: FetchData (12) - PStore (12)
- Thread (8)
-
YAML
:: DBM (12)
モジュール
- TSort (23)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - attr (12)
-
each
_ strongly _ connected _ component _ from (23) - new (24)
- tsort (12)
検索結果
先頭5件
-
PStore
# fetch(name , default = PStore :: Error) -> object (18231.0) -
ルートnameに対応する値を得ます。
...> []
ary = db["root"] = [1,2,3,4]
ary[0] = [1,1.5]
end
db.transaction(true) do |pstore|
pstore.fetch("root") # => [[1, 1.5], 2, 3, 4]
pstore.fetch("root", 'aaa') # => [[1, 1.5], 2, 3, 4]
pstore.fetch("not_root") # => 例外発生
end
@see Hash#fetch, PStore#[]... -
Hash
# [](key) -> object | nil (18212.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......value"
h2 = Hash.new {|*arg| arg}
p h2[:non] #=> [{}, :non]
//}
@see Hash.new, Hash#fetch,Hash#values_at,Hash#key?, Hash#default, Hash#default_proc... -
Thread
# [](name) -> object | nil (18206.0) -
name に対応したスレッドに固有のデータを取り出します。 name に対応するスレッド固有データがなければ nil を返し ます。
...nd
# => #<Thread:0x00000002a54220 dead>: A
# => #<Thread:0x00000002a541a8 dead>: B
# => #<Thread:0x00000002a54130 dead>: C
//}
Thread#[] と Thread#[]= を用いたスレッド固有の変数は
Fiber を切り替えると異なる変数を返す事に注意してください。
//emlist[][ruby]......合は動的スコープとしては
正しく動作しません。
//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 is leaked to outside of meth method.)
//}
Fibe......r を切り替えても同じ変数を返したい場合は
Thread#thread_variable_get と Thread#thread_variable_set
を使用してください。
@see Thread#fetch, Thread#[]=... -
YAML
:: DBM # [](key) -> object | nil (18206.0) -
データベースからキーを探して対応する要素の値を返します。
...データベースからキーを探して対応する要素の値を返します。
対応する値が見つからなかった場合は nil を返します。DBM#[] とは異
なり、IndexError は発生しません。
@param key キーを文字列で指定します。
@see YAML::DBM#fetch... -
Net
:: IMAP :: FetchData # attr -> { String => object } (3224.0) -
各メッセージのアトリビュートの値をハッシュテーブルで返します。
...::BodyTypeMessage, Net::IMAP::BodyTypeMultipart
のいずれか。
: BODY[<section>]<<partial>>
section で指定されたセクションのボディの内容。文字列。
: BODY.PEEK[<section>]<<partial>>
section で指定されたセクションのメッセージボディの内容。......: RFC822
BODY[] と同じ。文字列。
: RFC822.HEADER
BODY.PEEK[HEADER] と同じ。文字列。
: RFC822.SIZE
メッセージの 822 サイズ。整数。
: RFC822.TEXT
BODY[TEXT] と同じ。文字列。
: UID
UID。整数。
詳しくは 2060 の FETCH command の節を......見てください。
@see Net::IMAP#fetch, Net::IMAP#uid_fetch... -
TSort
# each _ strongly _ connected _ component _ from(node , id _ map={} , stack=[]) -> Enumerator (206.0) -
node から到達可能な強連結成分についてのイテレータです。
...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| . . . } -> () (206.0) -
node から到達可能な強連結成分についてのイテレータです。
...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... -
Hash
. new {|hash , key| . . . } -> Hash (107.0) -
空の新しいハッシュを生成します。ブロックの評価結果がデフォルト値になりま す。設定したデフォルト値はHash#default_procで参照できます。
...h.new("foo")
p h[1] #=> "foo"
p h[1].object_id #=> 6127170
p h[1] << "bar" #=> "foobar"
p h[1] #=> "foobar"
p h[2] #=> "foobar"
p h[2].object_id #=> 6127170
p h #=> {}
# ブロックを与えると、対......#=> "foo"
p h[1].object_id #=> 6126900
p h[1] << "bar" #=> "foobar"
p h[1] #=> "foobar"
p h[2] #=> "foo"
p h[2].object_id #=> 6126840
p h #=> {1=>"foobar", 2=>"foo"}
# 値が設定されていないときに(fetchの... -
Hash
. new(ifnone = nil) -> Hash (107.0) -
空の新しいハッシュを生成します。ifnone はキーに対 応する値が存在しない時のデフォルト値です。設定したデフォルト値はHash#defaultで参照できます。
...により、一箇所のデフォルト値の変更が他の値のデフォルト値にも影響します。
//emlist[][ruby]{
h = Hash.new([])
h[0] << 0
h[1] << 1
p h.default #=> [0, 1]
//}
これを避けるには、破壊的でないメソッドで再代入する必要が有ります。
また......y]{
h = Hash.new([])
p h[1] #=> []
p h[1].object_id #=> 6127150
p h[1] << "bar" #=> ["bar"]
p h[1] #=> ["bar"]
p h[2] #=> ["bar"]
p h[2].object_id #=> 6127150
p h #=> {}
h = Hash.new([].freeze)
h[0] +=...