1 |
|
/* |
2 |
|
* %W% %E% |
3 |
|
* |
4 |
< |
* Copyright 2005 Sun Microsystems, Inc. All rights reserved. |
4 |
> |
* Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
5 |
|
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. |
6 |
|
*/ |
7 |
|
|
8 |
|
package java.util; |
9 |
– |
import java.util.*; // for javadoc (till 6280605 is fixed) |
9 |
|
|
10 |
|
/** |
11 |
|
* The <code>Vector</code> class implements a growable array of |
146 |
|
* @since 1.2 |
147 |
|
*/ |
148 |
|
public Vector(Collection<? extends E> c) { |
149 |
< |
Object[] a = c.toArray(); |
150 |
< |
elementCount = a.length; |
151 |
< |
// If c.toArray incorrectly doesn't return Object[], copy it. |
152 |
< |
if (a.getClass() == Object[].class) |
153 |
< |
elementData = a; |
155 |
< |
else |
156 |
< |
elementData = Arrays.copyOf(a, a.length, Object[].class); |
149 |
> |
elementData = c.toArray(); |
150 |
> |
elementCount = elementData.length; |
151 |
> |
// c.toArray might (incorrectly) not return Object[] (see 6260652) |
152 |
> |
if (elementData.getClass() != Object[].class) |
153 |
> |
elementData = Arrays.copyOf(elementData, elementCount, Object[].class); |
154 |
|
} |
155 |
|
|
156 |
|
/** |
1085 |
|
public boolean hasNext() { |
1086 |
|
// Racy but within spec, since modifications are checked |
1087 |
|
// within or after synchronization in next/previous |
1088 |
< |
return cursor < Vector.this.elementCount; |
1088 |
> |
return cursor != elementCount; |
1089 |
|
} |
1090 |
|
|
1091 |
|
public boolean hasPrevious() { |
1092 |
< |
return cursor > 0; |
1092 |
> |
return cursor != 0; |
1093 |
|
} |
1094 |
|
|
1095 |
|
public int nextIndex() { |