Module: BitsCount::IO
- Defined in:
- lib/bits_count/io.rb
Constant Summary collapse
- BUFFER_SIZE =
256- UNPACK_PATTERN =
"N*"- BIN_STR_END =
[0].pack("N")
Class Method Summary collapse
- .population_count_int32(io) ⇒ Object
- .population_count_map(io) ⇒ Object
- .population_count_str(io) ⇒ Object
Class Method Details
.population_count_int32(io) ⇒ Object
10 11 12 13 14 |
# File 'lib/bits_count/io.rb', line 10 def population_count_int32(io) count = 0 each_int32(io) {|int| count += Primitive.population_count_int32(int) } count end |
.population_count_map(io) ⇒ Object
16 17 18 19 20 |
# File 'lib/bits_count/io.rb', line 16 def population_count_map(io) count = 0 each_int32(io) {|int| count += Primitive.population_count_map(int) } count end |
.population_count_str(io) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/bits_count/io.rb', line 22 def population_count_str(io) count = 0 while binstr = io.read(BUFFER_SIZE) count += Primitive.population_count_str(binstr) end count end |