Class: BitArray
- Inherits:
-
Object
- Object
- BitArray
- Defined in:
- lib/rpl/interpreter.rb
Instance Method Summary collapse
- #[](position) ⇒ Object
- #[]=(position, value) ⇒ Object
-
#initialize ⇒ BitArray
constructor
A new instance of BitArray.
Constructor Details
#initialize ⇒ BitArray
Returns a new instance of BitArray.
11 12 13 |
# File 'lib/rpl/interpreter.rb', line 11 def initialize @mask = 0 end |
Instance Method Details
#[](position) ⇒ Object
23 24 25 |
# File 'lib/rpl/interpreter.rb', line 23 def [](position) @mask[position] end |
#[]=(position, value) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rpl/interpreter.rb', line 15 def []=(position, value) if value.zero? @mask ^= (1 << position) else @mask |= (1 << position) end end |