Sha256: 7d550810235ebf621a0aa7952755e565221b197295071601c0781431c5a7de1c
Contents?: true
Size: 895 Bytes
Versions: 1
Compression:
Stored size: 895 Bytes
Contents
module BitsCount module IO BUFFER_SIZE = 256 UNPACK_PATTERN = "N*" BIN_STR_END = [0].pack("N") class << self def population_count_int32(io) count = 0 each_int32(io) {|int| count += Primitive.population_count_int32(int) } count end def population_count_map(io) count = 0 each_int32(io) {|int| count += Primitive.population_count_map(int) } count end def population_count_str(io) count = 0 while binstr = io.read(BUFFER_SIZE) count += Primitive.population_count_str(binstr) end count end private def each_int32(io, &block) while binstr = io.read(BUFFER_SIZE) binstr << BIN_STR_END if binstr.bytesize < BUFFER_SIZE binstr.unpack(UNPACK_PATTERN).each(&block) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bits_count-0.0.1 | lib/bits_count/io.rb |