Changeset 3976
 Timestamp:
 Oct 17, 2008, 6:02:46 PM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

toimperative/branches/java_expr_without_holes/Expr.java
r3975 r3976 8 8 9 9 import java.util.ArrayList; 10 import java.util.LinkedList;11 10 import java.util.List; 12 11 import java.util.ListIterator; … … 26 25 */ 27 26 public static int no_copy = 0; 28 public static int left_copy = 0;29 public static int right_copy = 0;30 27 public static int both_copy = 0; 31 28 32 private static Comparable<?>[] terms_pool = new Comparable[8];33 private static int pool_index = 0;34 35 29 private final Comparable<?>[] terms; 36 30 private final int start; … … 136 130 Comparable<?>[] terms1 = expr.terms; 137 131 int k1 = expr.start + j; 138 int tslen = terms.length;139 132 int k = start; 140 133 if (terms == terms1 && k == k1) … … 171 164 * Compares this expression with the specified expression for order. 172 165 */ 166 @SuppressWarnings("unchecked") 173 167 public int compareTo (Expr expr) { 174 168 assert expr != null : "expr="+expr; … … 183 177 compare_len = 0; 184 178 Comparable<?>[] terms1 = expr.terms; 185 int tslen1 = terms1.length;186 179 int k1 = expr.start; 187 int tslen = terms.length;188 180 int k = start; 189 181 for ( ; min_len > 0; min_len, k++, k1++) { … … 235 227 public static Expr concat (Comparable<?> obj1, Comparable<?> obj2) { 236 228 assert obj1 != null && obj2 != null : "obj1="+obj1+", obj2="+obj2; 237 if (pool_index >= terms_pool.length  1) { 238 terms_pool = new Comparable[8]; 239 pool_index = 0; 240 } 241 terms_pool[pool_index++] = obj1; 242 terms_pool[pool_index++] = obj2; 243 return new Expr(terms_pool, pool_index  2, 2); 229 return new Expr(new Comparable[] {obj1, obj2}, 0, 2); 244 230 } 245 231 … … 287 273 public static Expr create (Comparable<?> term) { 288 274 assert term != null : "term=" + term; 289 if (pool_index >= terms_pool.length) { 290 terms_pool = new Comparable[8]; 291 pool_index = 0; 292 } 293 terms_pool[pool_index] = term; 294 return new Expr(terms_pool, pool_index++, 1); 275 return new Expr(new Comparable[] {term}, 0, 1); 295 276 } 296 277 … … 556 537 private int length; 557 538 558 private InplaceConcatenator reinit (int initialCapacity) {559 terms = new Comparable[initialCapacity];560 length = 0;561 return this;562 }563 564 private InplaceConcatenator () {565 terms = null;566 length = 0;567 }568 569 539 public InplaceConcatenator (int initialCapacity) { 570 540 assert initialCapacity >= 0;
Note: See TracChangeset
for help on using the changeset viewer.