Class: Gecode::Util::BoolVarStore
- Inherits:
-
Object
- Object
- Gecode::Util::BoolVarStore
- Includes:
- VarStoreMethods
- Defined in:
- lib/gecoder/interface/binding_changes.rb
Overview
A store in which int variables are created and stored.
Instance Method Summary collapse
-
#initialize(space) ⇒ BoolVarStore
constructor
Creates a store for the specified space with the specified capacit.
-
#new_vars(count = 1) ⇒ Object
Creates the specified number of new bool variables.
Methods included from VarStoreMethods
Constructor Details
#initialize(space) ⇒ BoolVarStore
Creates a store for the specified space with the specified capacit.
178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/gecoder/interface/binding_changes.rb', line 178 def initialize(space) @space = space @var_array = space.bool_var_array(ARRAY_IDENTIFIER) if @var_array.nil? # Create a new one. @var_array = new_storage_array(0) end @size = @var_array.size @next_index = @size end |
Instance Method Details
#new_vars(count = 1) ⇒ Object
Creates the specified number of new bool variables. Returns the indices of the created variables as an array.
193 194 195 196 197 198 199 200 201 |
# File 'lib/gecoder/interface/binding_changes.rb', line 193 def new_vars(count = 1) grow(@next_index + count) # See the design note for more information. count.times do |i| @var_array[@next_index] = Gecode::Raw::BoolVar.new(@space, 0, 1) @next_index += 1 end ((@next_index - count)...@next_index).to_a end |