/vqdr/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/vqdr/trunk

« back to all changes in this revision

Viewing changes to src/libvqdr/function/roll_and_keep_functon_token.vala

  • Committer: Gustav Hartvigsson
  • Date: 2022-06-01 12:30:01 UTC
  • mfrom: (52.1.3 int64)
  • Revision ID: gustav.hartvigsson@gmail.com-20220601123001-b5xs60wwym810hg1
Merged: lp:~gustav.hartvigsson/vqdr/int64

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
using Utils;
3
3
 
4
4
public class VQDR.Expression.RollAndKeepFunctionToken : FunctionToken {
5
 
  private const int INDEX_ROLL = 1;
6
 
  private const int INDEX_POOL = 1;
7
 
  private const int INDEX_KEEP = 2;
8
 
 
9
 
  private const int MAX_POOL_SIZE = 50;
10
 
 
11
 
  private long[] roll_values  = null; // = new long[MAX_POOL_SIZE];
 
5
  private const int32 INDEX_ROLL = 1;
 
6
  private const int32 INDEX_POOL = 1;
 
7
  private const int32 INDEX_KEEP = 2;
 
8
 
 
9
  private const int32 MAX_POOL_SIZE = 50;
 
10
 
 
11
  private int64[] roll_values  = null; // = new long[MAX_POOL_SIZE];
12
12
  private bool[] valid_values = null; // = new bool[MAX_POOL_SIZE];
13
13
 
14
14
  construct {
18
18
 
19
19
  protected override void evaluate_self (VQDR.Expression.Context instance) throws GLib.Error {
20
20
    Token? roll;
21
 
    long  pool_size;
22
 
    long keep_size;
 
21
    int64  pool_size;
 
22
    int64 keep_size;
23
23
    
24
24
    roll = get_child (INDEX_ROLL);
25
25
    try {
56
56
 
57
57
    /* */
58
58
 
59
 
    long roll_result;
60
 
    long min_keep = long.MAX;
61
 
    int min_keep_index = 0;
 
59
    int64 roll_result;
 
60
    int64 min_keep = int64.MAX;
 
61
    int32 min_keep_index = 0;
62
62
    
63
63
    if (roll_values == null || roll_values.length < pool_size) {
64
 
      roll_values  = new long[pool_size];
 
64
      roll_values  = new int64[pool_size];
65
65
      valid_values = new bool[pool_size];
66
66
    }
67
67
 
68
 
    for (int i = 0; i < pool_size; i++) {
 
68
    for (int32 i = 0; i < pool_size; i++) {
69
69
      roll.evaluate (instance);
70
70
      roll_result = roll.result_value.raw_number;
71
71
      
85
85
          valid_values[min_keep_index] = false;
86
86
 
87
87
          // Search for new Minimum value
88
 
          min_keep = long.MAX;
 
88
          min_keep = int64.MAX;
89
89
          min_keep_index = 0;
90
90
 
91
 
          for (int j = 0; j <= i; j++) {
 
91
          for (int32 j = 0; j <= i; j++) {
92
92
            if (valid_values[j]) {
93
93
              if (min_keep > roll_values[j]) {
94
94
                min_keep = roll_values[j];
107
107
    
108
108
    FastNumber tmp_fstnmbr;
109
109
 
110
 
    for (int i = 0; i < pool_size; i++) {
 
110
    for (int32 i = 0; i < pool_size; i++) {
111
111
      if (strbldr.len < MAX_TOKEN_STRING_LENGTH) {
112
112
        //we don't start with a seperator mark.
113
113
        if (i > 0) {