class TypeProf::Core::Set
Public Class Methods
[](*elems)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/util.rb, line 3 def self.[](*elems) h = Hash.new(false) elems.each {|elem| h[elem] = true } new(h) end
new(hash)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/util.rb, line 9 def initialize(hash) @hash = hash end
Public Instance Methods
-(other)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/util.rb, line 58 def -(other) h = @hash.dup other.each do |elem| h.delete(elem) end Set.new(h) end
<<(elem)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/util.rb, line 19 def <<(elem) raise if @hash.include?(elem) @hash[elem] = true self end
clear()
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/util.rb, line 46 def clear @hash.clear end
delete(elem)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/util.rb, line 41 def delete(elem) raise unless @hash.include?(elem) @hash.delete(elem) end
dup()
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/util.rb, line 15 def dup Set.new(@hash.dup) end
each(&blk)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/util.rb, line 33 def each(&blk) @hash.each_key(&blk) end
empty?()
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/util.rb, line 37 def empty? @hash.empty? end
include?(elem)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/util.rb, line 25 def include?(elem) @hash[elem] end
internal_hash(= @hash)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/util.rb, line 13 def internal_hash = @hash def dup Set.new(@hash.dup) end def <<(elem) raise if @hash.include?(elem) @hash[elem] = true self end def include?(elem) @hash[elem] end def merge(set) raise NotImplementedError end def each(&blk) @hash.each_key(&blk) end def empty? @hash.empty? end def delete(elem) raise unless @hash.include?(elem) @hash.delete(elem) end def clear @hash.clear end def to_a @hash.keys end def size @hash.size end def -(other) h = @hash.dup other.each do |elem| h.delete(elem) end Set.new(h) end def pretty_print(q) q.text "Set[" q.group do q.nest(1) do @hash.each_key do |elem| q.breakable "" q.pp elem q.text "," end end q.breakable "" end q.text "]" end end
merge(set)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/util.rb, line 29 def merge(set) raise NotImplementedError end
pretty_print(q)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/util.rb, line 66 def pretty_print(q) q.text "Set[" q.group do q.nest(1) do @hash.each_key do |elem| q.breakable "" q.pp elem q.text "," end end q.breakable "" end q.text "]" end
size()
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/util.rb, line 54 def size @hash.size end
to_a()
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/util.rb, line 50 def to_a @hash.keys end