Sha256: ac9a25b161cdd761d5812e20e41f01692699c76651c2b510bf52b23899fbe2bc

Contents?: true

Size: 384 Bytes

Versions: 1

Compression:

Stored size: 384 Bytes

Contents

# frozen_string_literal: true

module Lrama
  module Bitmap
    def self.from_array(ary)
      bit = 0

      ary.each do |int|
        bit |= (1 << int)
      end

      bit
    end

    def self.to_array(int)
      a = []
      i = 0

      while int > 0 do
        if int & 1 == 1
          a << i
        end

        i += 1
        int >>= 1
      end

      a
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lrama-0.6.10 lib/lrama/bitmap.rb