class Racc::ISet

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

Attributes

set[R]

Public Class Methods

new(a = []) click to toggle source
# File racc-1.7.3/lib/racc/iset.rb, line 18
def initialize(a = [])
  @set = a
end

Public Instance Methods

[](key) click to toggle source
# File racc-1.7.3/lib/racc/iset.rb, line 28
def [](key)
  @set[key.ident]
end
Also aliased as: include?, key?
[]=(key, val) click to toggle source
# File racc-1.7.3/lib/racc/iset.rb, line 32
def []=(key, val)
  @set[key.ident] = val
end
add(i) click to toggle source
# File racc-1.7.3/lib/racc/iset.rb, line 24
def add(i)
  @set[i.ident] = i
end
clear() click to toggle source
# File racc-1.7.3/lib/racc/iset.rb, line 82
def clear
  @set.clear
end
delete(key) click to toggle source
# File racc-1.7.3/lib/racc/iset.rb, line 54
def delete(key)
  i = @set[key.ident]
  @set[key.ident] = nil
  i
end
dup() click to toggle source
# File racc-1.7.3/lib/racc/iset.rb, line 86
def dup
  ISet.new(@set.dup)
end
each(&block) click to toggle source
# File racc-1.7.3/lib/racc/iset.rb, line 60
def each(&block)
  @set.compact.each(&block)
end
empty?() click to toggle source
# File racc-1.7.3/lib/racc/iset.rb, line 78
def empty?
  @set.nitems == 0
end
include?(key)
Alias for: []
inspect()
Alias for: to_s
key?(key)
Alias for: []
size() click to toggle source
# File racc-1.7.3/lib/racc/iset.rb, line 74
def size
  @set.nitems
end
to_a() click to toggle source
# File racc-1.7.3/lib/racc/iset.rb, line 64
def to_a
  @set.compact
end
to_s() click to toggle source
# File racc-1.7.3/lib/racc/iset.rb, line 68
def to_s
  "[#{@set.compact.join(' ')}]"
end
Also aliased as: inspect
update(other) click to toggle source
# File racc-1.7.3/lib/racc/iset.rb, line 39
def update(other)
  s = @set
  o = other.set
  o.each_index do |idx|
    if t = o[idx]
      s[idx] = t
    end
  end
end
update_a(a) click to toggle source
# File racc-1.7.3/lib/racc/iset.rb, line 49
def update_a(a)
  s = @set
  a.each {|i| s[i.ident] = i }
end