class WeakSet

Public Class Methods

new(val_class) click to toggle source
Calls superclass method WeakStore.new
# File core/lib/weakstorage.rb, line 219
def initialize(val_class)
  @val_class = val_class
  super()
end

Public Instance Methods

<<(val)
Alias for: add
add(val) click to toggle source
# File core/lib/weakstorage.rb, line 232
def add(val)
  type_strict val => @val_class
  ObjectSpace.define_finalizer(val, &gen_deleter)
  atomic{
    storage.add(val.object_id) } end
Also aliased as: <<
each() { |_id2ref| ... } click to toggle source
# File core/lib/weakstorage.rb, line 224
def each
  begin
    atomic{
      storage.each{ |n| yield(ObjectSpace._id2ref(n)) } }
  rescue RangeError => e
    error e
    nil end end
inspect() click to toggle source
# File core/lib/weakstorage.rb, line 239
def inspect
  atomic{ "#<WeakSet(#{@val_class}): #{storage.size}>" }
end