src/share/classes/com/sun/tools/javac/util/List.java

changeset 816
7c537f4298fb
parent 798
4868a36f6fd8
child 1347
1408af4cd8b0
equal deleted inserted replaced
815:d17f37522154 816:7c537f4298fb
1 /* 1 /*
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
182 if (xs.isEmpty()) return this; 182 if (xs.isEmpty()) return this;
183 if (xs.tail.isEmpty()) return prepend(xs.head); 183 if (xs.tail.isEmpty()) return prepend(xs.head);
184 // return this.prependList(xs.tail).prepend(xs.head); 184 // return this.prependList(xs.tail).prepend(xs.head);
185 List<A> result = this; 185 List<A> result = this;
186 List<A> rev = xs.reverse(); 186 List<A> rev = xs.reverse();
187 assert rev != xs; 187 Assert.check(rev != xs);
188 // since xs.reverse() returned a new list, we can reuse the 188 // since xs.reverse() returned a new list, we can reuse the
189 // individual List objects, instead of allocating new ones. 189 // individual List objects, instead of allocating new ones.
190 while (rev.nonEmpty()) { 190 while (rev.nonEmpty()) {
191 List<A> h = rev; 191 List<A> h = rev;
192 rev = rev.tail; 192 rev = rev.tail;

mercurial