Class: Bud::SetLattice
Overview
A set lattice contains zero or more primitive (non-lattice) values.
Direct Known Subclasses
Instance Method Summary (collapse)
-
- (SetLattice) initialize(i = Set.new)
constructor
A new instance of SetLattice.
-
- (Object) inspect
Override default “inspect” implementation to produce slightly nicer output.
- - (Object) merge(i)
-
- (Object) probe(val, preds)
Assuming that this set contains Structs, this method takes a value “val” and a hash of predicates “preds”.
Methods inherited from Lattice
#<=>, #==, #eql?, global_mfuncs, global_morphs, #hash, lattice_kinds, mfuncs, monotone, morph, morphs, #reject_input, #reveal, #wrap_unsafe, wrapper, wrapper_name
Constructor Details
- (SetLattice) initialize(i = Set.new)
A new instance of SetLattice
226 227 228 229 230 231 232 |
# File 'lib/bud/lattice-lib.rb', line 226 def initialize(i=Set.new) reject_input(i) unless i.kind_of? Enumerable reject_input(i) if i.any? {|e| e.kind_of? Bud::Lattice} i = Set.new(i) unless i.kind_of? Set @v = i end |
Instance Method Details
- (Object) inspect
Override default “inspect” implementation to produce slightly nicer output
239 240 241 |
# File 'lib/bud/lattice-lib.rb', line 239 def inspect "<#{self.class.wrapper}: #{reveal.to_a.sort.inspect}>" end |
- (Object) merge(i)
234 235 236 |
# File 'lib/bud/lattice-lib.rb', line 234 def merge(i) wrap_unsafe(@v | i.reveal) end |
- (Object) probe(val, preds)
294 295 296 297 298 299 300 301 |
# File 'lib/bud/lattice-lib.rb', line 294 def probe(val, preds) return @v if preds.empty? probe_val = schema_fetch(val, preds.keys) build_index(preds.values) index = @join_indexes[preds.values] return index[probe_val] || [] end |