test/tools/javac/util/list/TList.java

Mon, 01 Jun 2015 15:19:54 -0700

author
darcy
date
Mon, 01 Jun 2015 15:19:54 -0700
changeset 3834
45746e46893b
parent 554
9d9f26857129
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8075546: Add tiered testing definitions to the langtools repo
Reviewed-by: jjg

duke@1 1 /*
ohair@554 2 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation.
duke@1 8 *
duke@1 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 13 * accompanied this code).
duke@1 14 *
duke@1 15 * You should have received a copy of the GNU General Public License version
duke@1 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 18 *
ohair@554 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 20 * or visit www.oracle.com if you need additional information or have any
ohair@554 21 * questions.
duke@1 22 */
duke@1 23
duke@1 24 /*
duke@1 25 * @test
duke@1 26 * @bug 6267067 6351336 6389198
duke@1 27 * @summary unit test for javac List
duke@1 28 */
duke@1 29
duke@1 30 import java.util.*;
duke@1 31 import com.sun.tools.javac.util.List;
duke@1 32
duke@1 33 public class TList {
duke@1 34 public static void main(String[] args) {
duke@1 35 new TList().run();
duke@1 36 }
duke@1 37
duke@1 38 String[][] data = {
duke@1 39 { },
duke@1 40 { "1" },
duke@1 41 { "1", "2" },
duke@1 42 { "1", "2" }, // different but equal
duke@1 43 { "1", "2", "3", "4", "X", "X", "X", "8", "9", "10" } // contains duplicates
duke@1 44 };
duke@1 45
duke@1 46 Map<java.util.List<String>,List<String>> examples;
duke@1 47
duke@1 48 void run() {
duke@1 49 examples = new LinkedHashMap<java.util.List<String>,List<String>>();
duke@1 50 for (String[] values: data)
duke@1 51 examples.put(Arrays.asList(values), createList(values));
duke@1 52
duke@1 53 // 6351336: com.sun.tools.javac.util.List shouldn't extend java.util.AbstractList
duke@1 54 test_AbstractList();
duke@1 55
duke@1 56 // general unit tests for java.util.List methods, including...
duke@1 57 // 6389198: com.sun.tools.javac.util.List.equals() violates java.util.List.equals() contract
duke@1 58 test_add_E();
duke@1 59 test_add_int_E();
duke@1 60 test_addAll_Collection();
duke@1 61 test_addAll_int_Collection();
duke@1 62 test_clear();
duke@1 63 test_contains_Object();
duke@1 64 test_contains_All();
duke@1 65 test_equals_Object();
duke@1 66 test_get_int();
duke@1 67 test_hashCode();
duke@1 68 test_indexOf_Object();
duke@1 69 test_isEmpty();
duke@1 70 test_iterator();
duke@1 71 test_lastIndexOf_Object();
duke@1 72 test_listIterator();
duke@1 73 test_listIterator_int();
duke@1 74 test_remove_int();
duke@1 75 test_remove_Object();
duke@1 76 test_removeAll_Collection();
duke@1 77 test_retainAll_Collection();
duke@1 78 test_set_int_E();
duke@1 79 test_size();
duke@1 80 test_subList_int_int();
duke@1 81 test_toArray();
duke@1 82 test_toArray_TArray();
duke@1 83
duke@1 84 // tests for additional methods
duke@1 85 test_prependList_List();
duke@1 86 test_reverse();
duke@1 87 }
duke@1 88
duke@1 89 // 6351336
duke@1 90 void test_AbstractList() {
duke@1 91 System.err.println("test AbstractList");
duke@1 92 if (AbstractList.class.isAssignableFrom(List.class))
duke@1 93 throw new AssertionError();
duke@1 94 }
duke@1 95
duke@1 96 void test_add_E() {
duke@1 97 System.err.println("test add(E)");
duke@1 98 for (List<String> l: examples.values()) {
duke@1 99 try {
duke@1 100 l.add("test");
duke@1 101 throw new AssertionError();
duke@1 102 } catch (UnsupportedOperationException ex) {
duke@1 103 }
duke@1 104 }
duke@1 105 }
duke@1 106
duke@1 107 void test_add_int_E() {
duke@1 108 System.err.println("test add(int,E)");
duke@1 109 for (List<String> l: examples.values()) {
duke@1 110 try {
duke@1 111 l.add(0, "test");
duke@1 112 throw new AssertionError();
duke@1 113 } catch (UnsupportedOperationException ex) {
duke@1 114 }
duke@1 115 }
duke@1 116 }
duke@1 117
duke@1 118 void test_addAll_Collection() {
duke@1 119 System.err.println("test addAll(Collection)");
duke@1 120 for (List<String> l: examples.values()) {
duke@1 121 int l_size = l.size();
duke@1 122 for (java.util.List<String> arg: examples.keySet()) {
duke@1 123 try {
duke@1 124 boolean modified = l.addAll(arg);
duke@1 125 if (modified)
duke@1 126 throw new AssertionError();
duke@1 127 } catch (UnsupportedOperationException e) {
duke@1 128 }
duke@1 129 if (l.size() != l_size)
duke@1 130 throw new AssertionError();
duke@1 131 }
duke@1 132 }
duke@1 133 }
duke@1 134
duke@1 135 void test_addAll_int_Collection() {
duke@1 136 System.err.println("test addAll(int,Collection)");
duke@1 137 for (List<String> l: examples.values()) {
duke@1 138 int l_size = l.size();
duke@1 139 for (java.util.List<String> arg: examples.keySet()) {
duke@1 140 try {
duke@1 141 boolean modified = l.addAll(0, arg);
duke@1 142 if (modified)
duke@1 143 throw new AssertionError();
duke@1 144 } catch (UnsupportedOperationException e) {
duke@1 145 }
duke@1 146 if (l.size() != l_size)
duke@1 147 throw new AssertionError();
duke@1 148 }
duke@1 149 }
duke@1 150 }
duke@1 151
duke@1 152 void test_clear() {
duke@1 153 System.err.println("test clear()");
duke@1 154 for (List<String> l: examples.values()) {
duke@1 155 int l_size = l.size();
duke@1 156 try {
duke@1 157 l.clear();
duke@1 158 if (l_size > 0)
duke@1 159 throw new AssertionError();
duke@1 160 } catch (UnsupportedOperationException e) {
duke@1 161 }
duke@1 162 if (l.size() != l_size)
duke@1 163 throw new AssertionError();
duke@1 164 }
duke@1 165 }
duke@1 166
duke@1 167 void test_contains_Object() {
duke@1 168 System.err.println("test contains(Object)");
duke@1 169 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 170 java.util.List<String> ref = e.getKey();
duke@1 171 List<String> l = e.getValue();
duke@1 172 boolean expect = ref.contains("1");
duke@1 173 boolean found = l.contains("1");
duke@1 174 if (expect != found)
duke@1 175 throw new AssertionError();
duke@1 176 }
duke@1 177 }
duke@1 178
duke@1 179 void test_contains_All() {
duke@1 180 System.err.println("test containsAll()");
duke@1 181 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 182 java.util.List<String> ref = e.getKey();
duke@1 183 List<String> l = e.getValue();
duke@1 184 for (java.util.List<String> arg: examples.keySet()) {
duke@1 185 boolean expect = ref.containsAll(arg);
duke@1 186 boolean found = l.containsAll(arg);
duke@1 187 if (expect != found)
duke@1 188 throw new AssertionError();
duke@1 189 }
duke@1 190 }
duke@1 191 }
duke@1 192
duke@1 193 // 6389198
duke@1 194 void test_equals_Object() {
duke@1 195 System.err.println("test equals(Object)");
duke@1 196 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 197 java.util.List<String> ref = e.getKey();
duke@1 198 List<String> l = e.getValue();
duke@1 199 for (java.util.List<String> arg: examples.keySet()) {
duke@1 200 boolean expect = ref.equals(arg);
duke@1 201 boolean found = l.equals(arg);
duke@1 202 if (expect != found) {
duke@1 203 System.err.println("ref: " + ref);
duke@1 204 System.err.println("l: " + l);
duke@1 205 System.err.println("arg: " + arg);
duke@1 206 System.err.println("expect: " + expect + ", found: " + found);
duke@1 207 throw new AssertionError();
duke@1 208 }
duke@1 209 }
duke@1 210 }
duke@1 211 }
duke@1 212
duke@1 213 void test_get_int() {
duke@1 214 System.err.println("test get(int)");
duke@1 215 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 216 java.util.List<String> ref = e.getKey();
duke@1 217 List<String> l = e.getValue();
duke@1 218 for (int i = -1; i <= ref.size(); i++) {
duke@1 219 boolean expectException = i < 0 || i >= ref.size();
duke@1 220 String expectValue = (expectException ? null : ref.get(i));
duke@1 221 try {
duke@1 222 String foundValue = l.get(i);
duke@1 223 if (expectException || !equal(expectValue, foundValue))
duke@1 224 throw new AssertionError();
duke@1 225 } catch (IndexOutOfBoundsException ex) {
duke@1 226 if (!expectException)
duke@1 227 throw new AssertionError();
duke@1 228 }
duke@1 229 }
duke@1 230 }
duke@1 231 }
duke@1 232
duke@1 233 void test_hashCode() {
duke@1 234 System.err.println("test hashCode()");
duke@1 235 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 236 java.util.List<String> ref = e.getKey();
duke@1 237 List<String> l = e.getValue();
duke@1 238 long expect = ref.hashCode();
duke@1 239 long found = l.hashCode();
duke@1 240 if (expect != found) {
duke@1 241 System.err.println("ref: " + ref);
duke@1 242 System.err.println("l: " + l);
duke@1 243 System.err.println("expect: " + expect);
duke@1 244 System.err.println("found: " + found);
duke@1 245 throw new AssertionError();
duke@1 246 }
duke@1 247 }
duke@1 248 }
duke@1 249
duke@1 250 void test_indexOf_Object() {
duke@1 251 System.err.println("test indexOf(Object)");
duke@1 252 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 253 java.util.List<String> ref = e.getKey();
duke@1 254 List<String> l = e.getValue();
duke@1 255 for (int i = -1; i < ref.size(); i++) {
duke@1 256 String arg = (i == -1 ? "NOT IN LIST" : ref.get(i));
duke@1 257 int expect = ref.indexOf(arg);
duke@1 258 int found = l.indexOf(arg);
duke@1 259 if (expect != found)
duke@1 260 throw new AssertionError();
duke@1 261 }
duke@1 262 }
duke@1 263 }
duke@1 264
duke@1 265 void test_isEmpty() {
duke@1 266 System.err.println("test isEmpty()");
duke@1 267 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 268 java.util.List<String> ref = e.getKey();
duke@1 269 List<String> l = e.getValue();
duke@1 270 boolean expect = ref.isEmpty();
duke@1 271 boolean found = l.isEmpty();
duke@1 272 if (expect != found)
duke@1 273 throw new AssertionError();
duke@1 274 }
duke@1 275 }
duke@1 276
duke@1 277 void test_iterator() {
duke@1 278 System.err.println("test iterator()");
duke@1 279 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 280 java.util.List<String> ref = e.getKey();
duke@1 281 List<String> l = e.getValue();
duke@1 282 if (!equal(l.iterator(), ref.iterator()))
duke@1 283 throw new AssertionError();
duke@1 284 }
duke@1 285 }
duke@1 286
duke@1 287 void test_lastIndexOf_Object() {
duke@1 288 System.err.println("test lastIndexOf(Object)");
duke@1 289 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 290 java.util.List<String> ref = e.getKey();
duke@1 291 List<String> l = e.getValue();
duke@1 292 for (int i = -1; i < ref.size(); i++) {
duke@1 293 String arg = (i == -1 ? "NOT IN LIST" : ref.get(i));
duke@1 294 int expect = ref.lastIndexOf(arg);
duke@1 295 int found = l.lastIndexOf(arg);
duke@1 296 if (expect != found)
duke@1 297 throw new AssertionError();
duke@1 298 }
duke@1 299 }
duke@1 300 }
duke@1 301
duke@1 302 void test_listIterator() {
duke@1 303 System.err.println("test listIterator()");
duke@1 304 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 305 java.util.List<String> ref = e.getKey();
duke@1 306 List<String> l = e.getValue();
duke@1 307 if (!equal(l.listIterator(), ref.listIterator()))
duke@1 308 throw new AssertionError();
duke@1 309 }
duke@1 310 }
duke@1 311
duke@1 312 void test_listIterator_int() {
duke@1 313 System.err.println("test listIterator(int)");
duke@1 314 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 315 java.util.List<String> ref = e.getKey();
duke@1 316 List<String> l = e.getValue();
duke@1 317 for (int i = 0; i < ref.size(); i++) {
duke@1 318 if (!equal(l.listIterator(i), ref.listIterator(i)))
duke@1 319 throw new AssertionError();
duke@1 320 }
duke@1 321 }
duke@1 322 }
duke@1 323
duke@1 324 void test_remove_int() {
duke@1 325 System.err.println("test remove(int)");
duke@1 326 for (List<String> l: examples.values()) {
duke@1 327 try {
duke@1 328 l.remove(0);
duke@1 329 throw new AssertionError();
duke@1 330 } catch (UnsupportedOperationException ex) {
duke@1 331 }
duke@1 332 }
duke@1 333 }
duke@1 334
duke@1 335 void test_remove_Object() {
duke@1 336 System.err.println("test remove(Object)");
duke@1 337 for (List<String> l: examples.values()) {
duke@1 338 boolean hasX = l.contains("X");
duke@1 339 try {
duke@1 340 l.remove("X");
duke@1 341 if (hasX)
duke@1 342 throw new AssertionError();
duke@1 343 } catch (UnsupportedOperationException ex) {
duke@1 344 }
duke@1 345 }
duke@1 346 }
duke@1 347
duke@1 348 void test_removeAll_Collection() {
duke@1 349 System.err.println("test removeAll(Collection)");
duke@1 350 for (List<String> l: examples.values()) {
duke@1 351 int l_size = l.size();
duke@1 352 for (java.util.List<String> arg: examples.keySet()) {
duke@1 353 try {
duke@1 354 boolean modified = l.removeAll(arg);
duke@1 355 if (modified)
duke@1 356 throw new AssertionError();
duke@1 357 } catch (UnsupportedOperationException e) {
duke@1 358 }
duke@1 359 if (l.size() != l_size)
duke@1 360 throw new AssertionError();
duke@1 361 }
duke@1 362 }
duke@1 363 }
duke@1 364
duke@1 365 void test_retainAll_Collection() {
duke@1 366 System.err.println("test retainAll(Collection)");
duke@1 367 for (List<String> l: examples.values()) {
duke@1 368 int l_size = l.size();
duke@1 369 for (java.util.List<String> arg: examples.keySet()) {
duke@1 370 try {
duke@1 371 boolean modified = l.retainAll(arg);
duke@1 372 if (modified)
duke@1 373 throw new AssertionError();
duke@1 374 } catch (UnsupportedOperationException e) {
duke@1 375 }
duke@1 376 if (l.size() != l_size)
duke@1 377 throw new AssertionError();
duke@1 378 }
duke@1 379 }
duke@1 380 }
duke@1 381
duke@1 382 void test_set_int_E() {
duke@1 383 System.err.println("test set(int,E)");
duke@1 384 for (List<String> l: examples.values()) {
duke@1 385 try {
duke@1 386 l.set(0, "X");
duke@1 387 throw new AssertionError();
duke@1 388 } catch (UnsupportedOperationException ex) {
duke@1 389 }
duke@1 390 }
duke@1 391 }
duke@1 392
duke@1 393 void test_size() {
duke@1 394 System.err.println("test size()");
duke@1 395 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 396 java.util.List<String> ref = e.getKey();
duke@1 397 List<String> l = e.getValue();
duke@1 398 int expect = ref.size();
duke@1 399 int found = l.size();
duke@1 400 if (expect != found)
duke@1 401 throw new AssertionError();
duke@1 402 }
duke@1 403 }
duke@1 404
duke@1 405 void test_subList_int_int() {
duke@1 406 System.err.println("test subList(int,int)");
duke@1 407 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 408 java.util.List<String> ref = e.getKey();
duke@1 409 List<String> l = e.getValue();
duke@1 410 for (int lwb = 0; lwb < ref.size(); lwb++) {
duke@1 411 for (int upb = lwb; upb <= ref.size(); upb++) {
duke@1 412 if (!equal(l.subList(lwb, upb), ref.subList(lwb,upb)))
duke@1 413 throw new AssertionError();
duke@1 414 }
duke@1 415 }
duke@1 416 }
duke@1 417 }
duke@1 418
duke@1 419 void test_toArray() {
duke@1 420 System.err.println("test toArray()");
duke@1 421 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 422 java.util.List<String> ref = e.getKey();
duke@1 423 List<String> l = e.getValue();
duke@1 424 if (!equal(l.toArray(), ref.toArray()))
duke@1 425 throw new AssertionError();
duke@1 426 }
duke@1 427 }
duke@1 428
duke@1 429 void test_toArray_TArray() {
duke@1 430 System.err.println("test toArray(E[])");
duke@1 431 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 432 java.util.List<String> ref = e.getKey();
duke@1 433 List<String> l = e.getValue();
duke@1 434 if (!equal(l.toArray(new String[0]), ref.toArray(new String[0])))
duke@1 435 throw new AssertionError();
duke@1 436 }
duke@1 437 }
duke@1 438
duke@1 439 void test_prependList_List() {
duke@1 440 System.err.println("test prependList(List<E>)");
duke@1 441 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 442 java.util.List<String> ref = e.getKey();
duke@1 443 List<String> l = e.getValue();
duke@1 444 for (Map.Entry<java.util.List<String>, List<String>> arg_e: examples.entrySet()) {
duke@1 445 java.util.List<String> arg_ref = arg_e.getKey();
duke@1 446 List<String> arg = arg_e.getValue();
duke@1 447 java.util.List<String> expect = join(arg, ref);
duke@1 448 List<String> found = l.prependList(arg);
duke@1 449 // verify results, and that original and arg lists are unchanged
duke@1 450 if (!equal(expect, found)) {
duke@1 451 System.err.println("ref: " + ref);
duke@1 452 System.err.println("l: " + l);
duke@1 453 System.err.println("arg: " + arg);
duke@1 454 System.err.println("expect: " + expect);
duke@1 455 System.err.println("found: " + found);
duke@1 456 throw new AssertionError();
duke@1 457 }
duke@1 458 if (!equal(l, ref))
duke@1 459 throw new AssertionError();
duke@1 460 if (!equal(arg, arg_ref))
duke@1 461 throw new AssertionError();
duke@1 462 }
duke@1 463 }
duke@1 464 }
duke@1 465
duke@1 466 void test_reverse() {
duke@1 467 System.err.println("test reverse()");
duke@1 468 for (Map.Entry<java.util.List<String>,List<String>> e: examples.entrySet()) {
duke@1 469 java.util.List<String> ref = e.getKey();
duke@1 470 List<String> l = e.getValue();
duke@1 471 java.util.List<String> expect = reverse(ref);
duke@1 472 List<String> found = l.reverse();
duke@1 473 if (l.size() < 2 && found != l) // reverse of empty or singleton list is itself
duke@1 474 throw new AssertionError();
duke@1 475 if (!equal(l, ref)) // orginal should be unchanged
duke@1 476 throw new AssertionError();
duke@1 477 if (!equal(expect, found))
duke@1 478 throw new AssertionError();
duke@1 479 }
duke@1 480 }
duke@1 481
duke@1 482 static <T> com.sun.tools.javac.util.List<T> createList(List<T> d) {
duke@1 483 com.sun.tools.javac.util.List<T> l = com.sun.tools.javac.util.List.nil();
duke@1 484 for (ListIterator<T> iter = d.listIterator(d.size()); iter.hasPrevious(); )
duke@1 485 l = l.prepend(iter.previous());
duke@1 486 return l;
duke@1 487 }
duke@1 488
duke@1 489 static <T> com.sun.tools.javac.util.List<T> createList(T... d) {
duke@1 490 com.sun.tools.javac.util.List<T> l = com.sun.tools.javac.util.List.nil();
duke@1 491 for (int i = d.length - 1; i >= 0; i--)
duke@1 492 l = l.prepend(d[i]);
duke@1 493 return l;
duke@1 494 }
duke@1 495
duke@1 496 static <T> boolean equal(T t1, T t2) {
duke@1 497 return (t1 == null ? t2 == null : t1.equals(t2));
duke@1 498 }
duke@1 499
duke@1 500 static <T> boolean equal(Iterator<T> iter1, Iterator<T> iter2) {
duke@1 501 if (iter1 == null || iter2 == null)
duke@1 502 return (iter1 == iter2);
duke@1 503
duke@1 504 while (iter1.hasNext() && iter2.hasNext()) {
duke@1 505 if (!equal(iter1.next(), iter2.next()))
duke@1 506 return false;
duke@1 507 }
duke@1 508
duke@1 509 return (!iter1.hasNext() && !iter2.hasNext());
duke@1 510 }
duke@1 511
duke@1 512 static <T> boolean equal(ListIterator<T> iter1, ListIterator<T> iter2) {
duke@1 513 if (iter1 == null || iter2 == null)
duke@1 514 return (iter1 == iter2);
duke@1 515
duke@1 516 if (iter1.previousIndex() != iter2.previousIndex())
duke@1 517 return false;
duke@1 518
duke@1 519 while (iter1.hasPrevious() && iter2.hasPrevious()) {
duke@1 520 iter1.previous();
duke@1 521 iter2.previous();
duke@1 522 }
duke@1 523
duke@1 524 return equal((Iterator<T>) iter1, (Iterator<T>) iter2);
duke@1 525 }
duke@1 526
duke@1 527 static <T> boolean equal(T[] a1, T[] a2) {
duke@1 528 if (a1 == null || a2 == null)
duke@1 529 return (a1 == a2);
duke@1 530
duke@1 531 if (a1.length != a2.length)
duke@1 532 return false;
duke@1 533
duke@1 534 for (int i = 0; i < a1.length; i++) {
duke@1 535 if (!equal(a1[i], a2[i]))
duke@1 536 return false;
duke@1 537 }
duke@1 538
duke@1 539 return true;
duke@1 540 }
duke@1 541
duke@1 542 static <T> java.util.List<T> join(java.util.List<T>... lists) {
duke@1 543 java.util.List<T> r = new ArrayList<T>();
duke@1 544 for (java.util.List<T> l: lists)
duke@1 545 r.addAll(l);
duke@1 546 return r;
duke@1 547 }
duke@1 548
duke@1 549 static <T> java.util.List<T> reverse(java.util.List<T> l) {
duke@1 550 java.util.List<T> r = new ArrayList<T>(l.size());
duke@1 551 for (T t: l)
duke@1 552 r.add(0, t);
duke@1 553 return r;
duke@1 554 }
duke@1 555 }

mercurial