Changeset 37154 for lang/cplusplus
 Timestamp:
 04/04/10 19:25:25 (6 years ago)
 Files:

 1 modified
Legend:
 Unmodified
 Added
 Removed

lang/cplusplus/libtable/table.h
r37153 r37154 37 37 } 38 38 //keep data when resizing 39 void resize(int x, int y) {39 void resize(int w, int h) { 40 40 //loop flag 41 41 int i; 42 int new_x, new_y; 42 //present direction 43 int now_x, now_y; 43 44 //when using vec1 44 45 if(flag == true) { … … 48 49 vec2.clear(); 49 50 //resize vec2 50 vec2.resize( x * y  1);51 vec2.resize(w * h); 51 52 //and copy data from vec1 52 for(i = 0; i < vec1.size(); i++) { 53 new_x = i % width; 54 new_y = i / height; 55 vec2[new_x + new_y * width] = vec1[i]; 53 while(1) { 54 now_x = i % width; 55 now_y = i / width; 56 if(now_x < w  now_y < h) { 57 break; 58 } 59 vec2[now_x + now_y * w] = vec1[i]; 56 60 } 57 61 } … … 63 67 vec1.clear(); 64 68 //resize vec2 65 vec1.resize( x * y  1);69 vec1.resize(w * h); 66 70 //and copy data from vec1 67 for(i = 0; i < vec2.size(); i++) { 68 new_x = i % width; 69 new_y = i / height; 70 vec1[new_x + new_y * width] = vec2[i]; 71 } 72 } 73 //change width data 74 width = x; 75 height = y; 71 while(1) { 72 now_x = i % width; 73 now_y = i / width; 74 if(now_x < w  now_y < h) { 75 break; 76 } 77 vec1[now_x + now_y * w] = vec2[i]; 78 } 79 } 80 //set new size 81 width = w; 82 height = h; 76 83 } 77 84 … … 120 127 for(i = 0; i < vec1.size(); i++) { 121 128 x = i % width; 122 y = i / height;129 y = i / width; 123 130 //set feature direction 124 131 new_x = (width  1  y); … … 137 144 for(i = 0; i < vec2.size(); i++) { 138 145 x = i % width; 139 y = i / height;146 y = i / width; 140 147 //set new direction 141 148 new_x = (width  1  y); … … 163 170 for(i = 0; i < vec1.size(); i++) { 164 171 x = i % width; 165 y = i / height;172 y = i / width; 166 173 //set new direction 167 174 new_x = y; … … 180 187 for(i = 0; i < vec2.size(); i++) { 181 188 x = i % width; 182 y = i / height;189 y = i / width; 183 190 //set new direction 184 191 new_x = y; … … 206 213 for(i = 0; i < vec1.size(); i++) { 207 214 x = i % width; 208 y = i / height;215 y = i / width; 209 216 //set new direction 210 217 new_x = (width  1  x); … … 222 229 for(i = 0; i < vec2.size(); i++) { 223 230 x = i % width; 224 y = i / height;231 y = i / width; 225 232 //set new direction 226 233 new_x = (width  1  x); … … 244 251 for(i = 0; i < vec1.size(); i++) { 245 252 x = i % width; 246 y = i / height;253 y = i / width; 247 254 //set new direction 248 255 new_x = x; … … 260 267 for(i = 0; i < vec2.size(); i++) { 261 268 x = i % width; 262 y = i / height;269 y = i / width; 263 270 //set new direction 264 271 new_x = x;