| 106 | |
| 107 | template<class View, class Val> |
| 108 | forceinline ExecStatus |
| 109 | Sequence<View,Val>::check(ViewArray<View>& x, Val s, int q, int l, int u) { |
| 110 | Region r; |
| 111 | // could do this with an array of length q... |
| 112 | int* upper = r.alloc<int>(x.size()+1); |
| 113 | int* lower = r.alloc<int>(x.size()+1); |
| 114 | upper[0] = 0; |
| 115 | lower[0] = 0; |
| 116 | for ( int j=0; j<x.size(); j++ ) { |
| 117 | upper[j+1] = upper[j]; |
| 118 | lower[j+1] = lower[j]; |
| 119 | if (includes(x[j],s)) { |
| 120 | upper[j+1] += 1; |
| 121 | } else if (excludes(x[j],s)) { |
| 122 | lower[j+1] += 1; |
| 123 | } |
| 124 | if ( j+1 >= q && (q - l < lower[j+1] - lower[j+1-q] || upper[j+1] - upper[j+1-q] > u) ) { |
| 125 | return ES_FAILED; |
| 126 | } |
| 127 | } |
| 128 | return ES_OK; |
| 129 | } |
| 130 | |
| 131 | template<class View, class Val> |
| 132 | ExecStatus |