Class: Set

Inherits:
Object
  • Object
show all
Defined in:
lib/core/set.rb

Instance Method Summary collapse

Instance Method Details

#r_adm(int) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/core/set.rb', line 3

def r_adm int
  # FIXME: consider an algorithm with lesser complexity
  seps = select { |sep| int & sep == sep }
  subblocks = Set[]
  int.bits.each do |elem|
    bit = 1 << elem
    subblock = subblocks.find { |sb| seps.none? { |sep| (sb | bit) & sep == sep } } || 0
    subblocks.delete subblock
    subblocks << (subblock | bit)
  end
  subblocks.size.log2_ceil
end