るりまサーチ

最速Rubyリファレンスマニュアル検索!
53件ヒット [1-53件を表示] (0.052秒)

別のキーワード

  1. argf.class lines
  2. argf.class each
  3. argf.class each_line
  4. class new
  5. argf.class to_a

モジュール

検索結果

Enumerable#max {|a, b| ... } -> object | nil (18180.0)

ブロックの評価結果で各要素の大小判定を行い、最大の要素、もしくは最大の n 要素が入った降順の配列を返します。 引数を指定しない形式では要素が存在しなければ nil を返します。 引数を指定する形式では、空の配列を返します。

...]{
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),
Person.new(...
..."tanaka", 55),
Person.new("tanaka", 33),
Person.new("tanaka", 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.n...

Enumerable#max(n) {|a, b| ... } -> Array (18180.0)

ブロックの評価結果で各要素の大小判定を行い、最大の要素、もしくは最大の n 要素が入った降順の配列を返します。 引数を指定しない形式では要素が存在しなければ nil を返します。 引数を指定する形式では、空の配列を返します。

...]{
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),
Person.new(...
..."tanaka", 55),
Person.new("tanaka", 33),
Person.new("tanaka", 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.n...

Enumerable#max -> object | nil (18130.0)

最大の要素、もしくは最大の n 要素が入った降順の配列を返します。 全要素が互いに <=> メソッドで比較できることを仮定しています。

...配列を返します。
該当する要素が複数存在する場合、どの要素を返すかは不定です。

@param n 取得する要素数。

//emlist[例][ruby]{
a = %w(albatross dog horse)
a.max # => "horse"
a.max(2) # => ["horse", "dog"]
//}...

Enumerable#max(n) -> Array (18130.0)

最大の要素、もしくは最大の n 要素が入った降順の配列を返します。 全要素が互いに <=> メソッドで比較できることを仮定しています。

...配列を返します。
該当する要素が複数存在する場合、どの要素を返すかは不定です。

@param n 取得する要素数。

//emlist[例][ruby]{
a = %w(albatross dog horse)
a.max # => "horse"
a.max(2) # => ["horse", "dog"]
//}...

Thread::ConditionVariable (86.0)

スレッドの同期機構の一つである状態変数を実現するクラスです。

...レッド a に対して条件が成立したことを通知します。これが典型的な
使用例です。

mutex = Mutex.new
cv = ConditionVariable.new

a = Thread.start {
mutex.synchronize {
...
while (条件が満たされない)
cv.wait(m...
...tion Variable を使って wait しています。

require 'thread'

class
TinyQueue
def initialize(max=2)
@max = max
@full = ConditionVariable.new
@empty = ConditionVariable.new
@mutex = Mutex.new
@q = []
end

def count
@q.size
end

def e...
...e{
@full.wait(@mutex) if count == @max
@q.push v
@empty.signal if count == 1
}
end

def deq
@mutex.synchronize{
@empty.wait(@mutex) if count == 0
v = @q.shift
@full.signal if count == (@max - 1)
v
}
end

alias...

絞り込み条件を変える