るりまサーチ

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

別のキーワード

  1. _builtin count
  2. array count
  3. enumerable count
  4. rubygems/user_interaction count
  5. matrix row_count

クラス

モジュール

キーワード

検索結果

<< < 1 2 3 4 > >>

ObjectSpace.#count_objects(result_hash = {}) -> Hash (6109.0)

オブジェクトを種類ごとにカウントした結果を Hash として返します。

...これを利用すると測定による影響を避けることができます。

@raise TypeError 引数に Hash 以外を与えた場合、発生します。

//emlist[例][ruby]{
ObjectSpace.count_objects # => {:TOTAL=>10000, :FREE=>3011, :T_OBJECT=>6, :T_CLASS=>404, ...}
//}...

ObjectSpace.#each_object -> Enumerator (50.0)

指定された klass と Object#kind_of? の関係にある全ての オブジェクトに対して繰り返します。引数が省略された時には全てのオブ ジェクトに対して繰り返します。 繰り返した数を返します。

...を扱う][ruby]{
ObjectSpace.each_object.take(5).each { |x| p x }
count
= ObjectSpace.each_object { |x| x }
puts "Total count: #{count}"

# => "scope"
# => "scopes"
# => "sym"
# => "class_names"
# => "@corrections"
# => Total count: 9938
//}

//emlist[例: 任意のクラスを扱う][ruby]{
Person...
...= Struct.new(:name)
s1 = Person.new("tanaka")
s2 = Person.new("sato")

count
= ObjectSpace.each_object(Person) { |x| p x }
puts "Total count: #{count}"

# => #<struct Person name="sato">
# => #<struct Person name="tanaka">
# => Total count: 2
//}...

ObjectSpace.#each_object {|object| ...} -> Integer (50.0)

指定された klass と Object#kind_of? の関係にある全ての オブジェクトに対して繰り返します。引数が省略された時には全てのオブ ジェクトに対して繰り返します。 繰り返した数を返します。

...を扱う][ruby]{
ObjectSpace.each_object.take(5).each { |x| p x }
count
= ObjectSpace.each_object { |x| x }
puts "Total count: #{count}"

# => "scope"
# => "scopes"
# => "sym"
# => "class_names"
# => "@corrections"
# => Total count: 9938
//}

//emlist[例: 任意のクラスを扱う][ruby]{
Person...
...= Struct.new(:name)
s1 = Person.new("tanaka")
s2 = Person.new("sato")

count
= ObjectSpace.each_object(Person) { |x| p x }
puts "Total count: #{count}"

# => #<struct Person name="sato">
# => #<struct Person name="tanaka">
# => Total count: 2
//}...

ObjectSpace.#each_object(klass) -> Enumerator (50.0)

指定された klass と Object#kind_of? の関係にある全ての オブジェクトに対して繰り返します。引数が省略された時には全てのオブ ジェクトに対して繰り返します。 繰り返した数を返します。

...を扱う][ruby]{
ObjectSpace.each_object.take(5).each { |x| p x }
count
= ObjectSpace.each_object { |x| x }
puts "Total count: #{count}"

# => "scope"
# => "scopes"
# => "sym"
# => "class_names"
# => "@corrections"
# => Total count: 9938
//}

//emlist[例: 任意のクラスを扱う][ruby]{
Person...
...= Struct.new(:name)
s1 = Person.new("tanaka")
s2 = Person.new("sato")

count
= ObjectSpace.each_object(Person) { |x| p x }
puts "Total count: #{count}"

# => #<struct Person name="sato">
# => #<struct Person name="tanaka">
# => Total count: 2
//}...

ObjectSpace.#each_object(klass) {|object| ...} -> Integer (50.0)

指定された klass と Object#kind_of? の関係にある全ての オブジェクトに対して繰り返します。引数が省略された時には全てのオブ ジェクトに対して繰り返します。 繰り返した数を返します。

...を扱う][ruby]{
ObjectSpace.each_object.take(5).each { |x| p x }
count
= ObjectSpace.each_object { |x| x }
puts "Total count: #{count}"

# => "scope"
# => "scopes"
# => "sym"
# => "class_names"
# => "@corrections"
# => Total count: 9938
//}

//emlist[例: 任意のクラスを扱う][ruby]{
Person...
...= Struct.new(:name)
s1 = Person.new("tanaka")
s2 = Person.new("sato")

count
= ObjectSpace.each_object(Person) { |x| p x }
puts "Total count: #{count}"

# => #<struct Person name="sato">
# => #<struct Person name="tanaka">
# => Total count: 2
//}...

絞り込み条件を変える

Thread#priority -> Integer (50.0)

スレッドの優先度を返します。この値が大きいほど優先度が高くなります。 メインスレッドのデフォルト値は 0 です。新しく生成されたスレッドは親スレッドの priority を引き継ぎます。

...][ruby]{
Thread.current.priority # => 0

count
1 = count2 = 0
a = Thread.new do
loop { count1 += 1 }
end
a.priority = -1

b = Thread.new do
loop { count2 += 1 }
end
b.priority = -2
count
1 = count2 = 0 # reset
sleep 1 # => 1
count
1 # => 13809431
count
2 # => 11571921
//}...

Thread#priority=(val) (50.0)

スレッドの優先度を返します。この値が大きいほど優先度が高くなります。 メインスレッドのデフォルト値は 0 です。新しく生成されたスレッドは親スレッドの priority を引き継ぎます。

...][ruby]{
Thread.current.priority # => 0

count
1 = count2 = 0
a = Thread.new do
loop { count1 += 1 }
end
a.priority = -1

b = Thread.new do
loop { count2 += 1 }
end
b.priority = -2
count
1 = count2 = 0 # reset
sleep 1 # => 1
count
1 # => 13809431
count
2 # => 11571921
//}...

Thread::ConditionVariable (32.0)

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

...[]
end

def count
@q.size
end

def enq(v)
@mutex.synchronize{
@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 send enq
alias recv deq
end

if __FILE__ == $0
q = TinyQueue.new(1)
foods = 'Apple Banana Strawberry Udon Rice Milk'.split
l = []

th = Thread.new {
for obj in foods
q.send(o...

BasicObject#! -> bool (26.0)

オブジェクトを真偽値として評価し、その論理否定を返します。

...ass NegationRecorder < BasicObject
def initialize
@count = 0
end
attr_reader :count

def !
@count += 1
super
end
end

recorder = NegationRecorder.new
!recorder
!!!!!!!recorder
puts 'hoge' if !recorder

puts recorder.count #=> 3
//}

//emlist[例][ruby]{
class AnotherFalse < Ba...
<< < 1 2 3 4 > >>