class Racc::ISet

An “indexed” set. All items must respond to :ident.

def [](key)

def [](key)
  @set[key.ident]
end

def []=(key, val)

def []=(key, val)
  @set[key.ident] = val
end

def add(i)

def add(i)
  @set[i.ident] = i
end

def clear

def clear
  @set.clear
end

def delete(key)

def delete(key)
  i = @set[key.ident]
  @set[key.ident] = nil
  i
end

def dup

def dup
  ISet.new(@set.dup)
end

def each(&block)

def each(&block)
  @set.compact.each(&block)
end

def empty?

def empty?
  @set.nitems == 0
end

def initialize(a = [])

def initialize(a = [])
  @set = a
end

def size

def size
  @set.nitems
end

def to_a

def to_a
  @set.compact
end

def to_s

def to_s
  "[#{@set.compact.join(' ')}]"
end

def update(other)

def update(other)
  s = @set
  o = other.set
  o.each_index do |idx|
    if t = o[idx]
      s[idx] = t
    end
  end
end

def update_a(a)

def update_a(a)
  s = @set
  a.each {|i| s[i.ident] = i }
end