Class: ConstraintSolver::ConstraintList

Inherits:
Array
  • Object
show all
Defined in:
lib/ConstraintList.rb

Overview

This class represents a list of constraints.

Instance Method Summary collapse

Methods inherited from Array

#eachAfter, #eachStartWith, #foldLeft, #rest

Instance Method Details

#-(element) ⇒ Object



26
27
28
29
# File 'lib/ConstraintList.rb', line 26

def -(element)
    new = self.to_a - (element.kind_of?(Array) ? element : [ element ])
    return ConstraintList.new(new)
end

#allWithVariable(variable) ⇒ Object

Returns the ConstraintList that contains all constraints that involve variable.



16
17
18
19
20
# File 'lib/ConstraintList.rb', line 16

def allWithVariable(variable)
    ConstraintList.new(self.select { |constraint|
	constraint.include?(variable)
    })
end

#notAllAssignedWithVariable(variable) ⇒ Object

Returns the ConstraintList that contains all constraints that involve variable and have values assigned to not all variables involved.



8
9
10
11
12
# File 'lib/ConstraintList.rb', line 8

def notAllAssignedWithVariable(variable)
    ConstraintList.new(self.select { |constraint|
	constraint.include?(variable) and not constraint.allAssigned?
    })
end

#sort(&block) ⇒ Object



22
23
24
# File 'lib/ConstraintList.rb', line 22

def sort(&block)
    ConstraintList.new(self.sort!(&block))
end