1
namespace VQDR.Expression {
5
* Represents a variable.
7
public struct Variable {
10
public int current_val;
12
public Variable (int min = 0, int max = 0, int current = 0) {
15
this.current_val = current;
18
[CCode (cname = "vqdr_expression_variable_copy")]
19
public Variable.copy (Variable other) {
20
this.max_val = other.max_val;
21
this.min_val = other.min_val;
22
this.current_val = other.current_val;
25
public int compare (Variable other) {
27
if (this.current_val > other.current_val) {
29
} else if (this.current_val < other.current_val) {
32
if (this.max_val > other.max_val) {
34
} else if (this.max_val < other.max_val) {
37
if (this.min_val > other.min_val) {
39
} else if (this.min_val < other.min_val) {
41
} // End min_val comp.
43
} // End current_val Comp
44
return 0; // They are exacly the same.
48
* Compares two Variables.
50
* This is the same as @c compare. It is an alias to the same C function.
52
[CCode (cname = "vqdr_expression_variable_equals")]
53
public static extern int static_compare (Variable a, Variable b);
56
* Is this instance equal to the other?
58
public bool equals (Variable other) {
59
return equals_values (other.min_val, other.max_val, other.current_val);
62
public bool equals_values (int min, int max, int current) {
63
return (max == this.max_val) &&
64
(min == this.min_val) &&
65
(current == this.current_val);
70
public string to_string () {
71
StringBuilder s = new StringBuilder ();
72
s.append("(Variable: ");
73
s.append_printf ("(max_val: %i, ", max_val);
74
s.append_printf ("min_val: %i, ", max_val);
75
s.append_printf ("current_val: %i)", current_val);