Sha256: 722baa09c8e60d1c173d4c687a5e29a86e3efaeca0db69846feb0ba064b9dc22
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
module TypeProf::Core class Set def self.[](*elems) h = Hash.new(false) elems.each {|elem| h[elem] = true } new(h) end def initialize(hash) @hash = hash end 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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
typeprof-0.30.1 | lib/typeprof/core/util.rb |
typeprof-0.30.0 | lib/typeprof/core/util.rb |