Sha256: 8e20de9128fd0e3968054e1b173d3c9d0dd935091dee27c9918fde886733cab4
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true require 'ragel/bitmap/version' module Ragel module Bitmap class Array8 def initialize(string) @string = string end def [](idx) @string.getbyte(idx) end end class Array16 def initialize(highstring, lowstring) @highstring = highstring @lowstring = lowstring end def [](idx) (@highstring.getbyte(idx) << 8) | @lowstring.getbyte(idx) end end class Array24 def initialize(highstring, middlestring, lowstring) @highstring = highstring @middlestring = middlestring @lowstring = lowstring end def [](idx) (@highstring.getbyte(idx) << 16) | (@middlestring.getbyte(idx) << 8) | @lowstring.getbyte(idx) end end class ArrayGeneric def initialize(*strings) @strings = strings end def [](idx) shift = @strings.length * 8 @strings.inject(0) do |product, bitmap| shift -= 8 product | (bitmap.getbyte(idx) << shift) end end end def self.replace(filepath) require 'ragel/bitmap/replace' File.write(filepath, Replace.replace(File.read(filepath))) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ragel-bitmap-0.2.0 | lib/ragel/bitmap.rb |