ライブラリ
- ビルトイン (358)
-
cgi
/ html (24) - date (24)
- json (12)
- openssl (24)
- optparse (24)
-
rexml
/ document (12) - socket (24)
- stringio (12)
- thread (10)
-
webrick
/ server (12) -
win32
/ registry (48) - zlib (12)
クラス
-
ARGF
. class (24) - Array (24)
- Date (24)
-
Encoding
:: Converter (24) - IO (44)
- Integer (24)
-
JSON
:: State (12) - OptionParser (24)
-
REXML
:: Element (12) -
RubyVM
:: InstructionSequence (12) - String (12)
- StringIO (12)
-
Thread
:: SizedQueue (60) - UDPSocket (12)
- UNIXSocket (12)
-
WEBrick
:: Cookie (12) -
WEBrick
:: GenericServer (12) -
Win32
:: Registry (48) -
Zlib
:: GzipReader (12)
モジュール
-
CGI
:: HtmlExtension (24) - Enumerable (144)
-
OpenSSL
:: Buffering (24)
キーワード
- << (12)
-
check
_ circular? (12) -
each
_ element _ with _ attribute (12) - enq (12)
- max= (12)
-
max
_ age= (12) -
max
_ by (48) -
max
_ value _ length (12) -
max
_ value _ name _ length (12) - minmax (24)
-
minmax
_ by (24) -
num
_ keys (12) -
num
_ values (12) -
password
_ field (12) - pread (8)
- push (12)
- putback (24)
-
read
_ nonblock (48) - readpartial (48)
- recvfrom (12)
-
recvfrom
_ nonblock (12) - shuffle! (24)
- summarize (24)
- sysread (12)
-
text
_ field (12) -
to
_ a (12) - tokens (12)
- upto (60)
検索結果
先頭5件
-
Thread
:: SizedQueue # max -> Integer (24108.0) -
キューの最大サイズを返します。
...キューの最大サイズを返します。
//emlist[例][ruby]{
q = SizedQueue.new(4)
q.max # => 4
//}... -
Enumerable
# max -> object | nil (21119.0) -
最大の要素、もしくは最大の n 要素が入った降順の配列を返します。 全要素が互いに <=> メソッドで比較できることを仮定しています。
...配列を返します。
該当する要素が複数存在する場合、どの要素を返すかは不定です。
@param n 取得する要素数。
//emlist[例][ruby]{
a = %w(albatross dog horse)
a.max # => "horse"
a.max(2) # => ["horse", "dog"]
//}... -
Enumerable
# max {|a , b| . . . } -> object | nil (21119.0) -
ブロックの評価結果で各要素の大小判定を行い、最大の要素、もしくは最大の n 要素が入った降順の配列を返します。 引数を指定しない形式では要素が存在しなければ nil を返します。 引数を指定する形式では、空の配列を返します。
...ist[例][ruby]{
class Person
attr_reader :name, :age
def initialize(name, age)
@name = name
@age = age
end
end
people = [
Person.new("sato", 55),
Person.new("sato", 33),
Person.new("sato", 11),
Person.new("suzuki", 55),
Person.new("suzuki", 33),
Person.new("suzuki", 11),......people.max { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => #<Person:0x007fc54b0240a0 @name="sato", @age=55>
people.max(2) { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => [#<Person:0x007fc54b0240a0 @name="sato", @age=55>, #<Person:0x007fc54c033ea0 @name="suzuki", @age... -
Enumerable
# max(n) -> Array (21119.0) -
最大の要素、もしくは最大の n 要素が入った降順の配列を返します。 全要素が互いに <=> メソッドで比較できることを仮定しています。
...配列を返します。
該当する要素が複数存在する場合、どの要素を返すかは不定です。
@param n 取得する要素数。
//emlist[例][ruby]{
a = %w(albatross dog horse)
a.max # => "horse"
a.max(2) # => ["horse", "dog"]
//}... -
Enumerable
# max(n) {|a , b| . . . } -> Array (21119.0) -
ブロックの評価結果で各要素の大小判定を行い、最大の要素、もしくは最大の n 要素が入った降順の配列を返します。 引数を指定しない形式では要素が存在しなければ nil を返します。 引数を指定する形式では、空の配列を返します。
...ist[例][ruby]{
class Person
attr_reader :name, :age
def initialize(name, age)
@name = name
@age = age
end
end
people = [
Person.new("sato", 55),
Person.new("sato", 33),
Person.new("sato", 11),
Person.new("suzuki", 55),
Person.new("suzuki", 33),
Person.new("suzuki", 11),......people.max { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => #<Person:0x007fc54b0240a0 @name="sato", @age=55>
people.max(2) { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => [#<Person:0x007fc54b0240a0 @name="sato", @age=55>, #<Person:0x007fc54c033ea0 @name="suzuki", @age... -
Thread
:: SizedQueue # max=(n) (12120.0) -
キューの最大サイズを設定します。
...キューの最大サイズを設定します。
@param n キューの最大サイズを指定します。
//emlist[例][ruby]{
require 'thread'
q = SizedQueue.new(4)
q.max # => 4
q.max = 5
q.max # => 5
//}......キューの最大サイズを設定します。
@param n キューの最大サイズを指定します。
//emlist[例][ruby]{
q = SizedQueue.new(4)
q.max # => 4
q.max = 5
q.max # => 5
//}... -
Enumerable
# max _ by -> Enumerator (9265.0) -
各要素を順番にブロックに渡して実行し、 その評価結果を <=> で比較して、 最大であった値に対応する元の要素、もしくは最大の n 要素が降順で入った配列を返します。
...です。
Enumerable#max と Enumerable#max_by の
違いは Enumerable#sort と Enumerable#sort_by の違いと同じです。
ブロックを省略した場合は Enumerator を返します。
@param n 取得する要素数。
//emlist[例][ruby]{
a = %w(albatross dog horse)
a.max_by......# => #<Enumerator: ["albatross", "dog", "horse"]:max_by>
a.max_by { |x| x.length } # => "albatross"
//}
//emlist[例][ruby]{
a = %w[albatross dog horse]
a.max_by(2) # => #<Enumerator: ["albatross", "dog", "horse"]:max_by(2)>
a.max_by(2) {|x| x.length } # => ["albatross",......//}
//emlist[例: enum.max_by(n)は、重み付きランダムサンプリングを実装するために使用できます。次の実装例は、Enumerable#wsampleを使用します。][ruby]{
module Enumerable
# weighted random sampling.
#
# Pavlos S. Efraimidis, Paul G. Spirakis
# We... -
Enumerable
# max _ by(n) -> Enumerator (9265.0) -
各要素を順番にブロックに渡して実行し、 その評価結果を <=> で比較して、 最大であった値に対応する元の要素、もしくは最大の n 要素が降順で入った配列を返します。
...です。
Enumerable#max と Enumerable#max_by の
違いは Enumerable#sort と Enumerable#sort_by の違いと同じです。
ブロックを省略した場合は Enumerator を返します。
@param n 取得する要素数。
//emlist[例][ruby]{
a = %w(albatross dog horse)
a.max_by......# => #<Enumerator: ["albatross", "dog", "horse"]:max_by>
a.max_by { |x| x.length } # => "albatross"
//}
//emlist[例][ruby]{
a = %w[albatross dog horse]
a.max_by(2) # => #<Enumerator: ["albatross", "dog", "horse"]:max_by(2)>
a.max_by(2) {|x| x.length } # => ["albatross",......//}
//emlist[例: enum.max_by(n)は、重み付きランダムサンプリングを実装するために使用できます。次の実装例は、Enumerable#wsampleを使用します。][ruby]{
module Enumerable
# weighted random sampling.
#
# Pavlos S. Efraimidis, Paul G. Spirakis
# We... -
Enumerable
# minmax _ by -> Enumerator (9201.0) -
Enumerable オブジェクトの各要素をブロックに渡して評価し、その結果を <=> で比較して 最小の要素と最大の要素を要素とするサイズ 2 の配列を返します。
...Enumerable オブジェクトの各要素をブロックに渡して評価し、その結果を <=> で比較して
最小の要素と最大の要素を要素とするサイズ 2 の配列を返します。
該当する要素が複数存在する場合、どの要素を返すかは不定です。......Enumerable#minmax と Enumerable#minmax_by の
違いは sort と sort_by の違いと同じです。
詳細は Enumerable#sort_by を参照してください。
//emlist[例][ruby]{
a = %w(albatross dog horse)
a.minmax_by {|x| x.length } #=> ["dog", "albatross"]
[].minmax_by{} # => [nil, nil]......//}
ブロックを省略した場合は Enumerator を返します。
@see Enumerable#sort_by...