1083 return new Object[0];
1084 }
1085
1086 /**
1087 * Sets the zeroth element of the specified array to {@code null}
1088 * (if the array has non-zero length) and returns it.
1089 *
1090 * @param a the array
1091 * @return the specified array
1092 * @throws NullPointerException if the specified array is null
1093 */
1094 public <T> T[] toArray(T[] a) {
1095 if (a.length > 0)
1096 a[0] = null;
1097 return a;
1098 }
1099
1100 /**
1101 * Always returns {@code "[]"}.
1102 * @return {@code "[]"}
1103 */
1104 public String toString() {
1105 return "[]";
1106 }
1107
1108 /**
1109 * @throws UnsupportedOperationException {@inheritDoc}
1110 * @throws ClassCastException {@inheritDoc}
1111 * @throws NullPointerException {@inheritDoc}
1112 * @throws IllegalArgumentException {@inheritDoc}
1113 */
1114 public int drainTo(Collection<? super E> c) {
1115 Objects.requireNonNull(c);
1116 if (c == this)
1117 throw new IllegalArgumentException();
1118 int n = 0;
1119 for (E e; (e = poll()) != null; n++)
1120 c.add(e);
1121 return n;
1122 }
|
1083 return new Object[0];
1084 }
1085
1086 /**
1087 * Sets the zeroth element of the specified array to {@code null}
1088 * (if the array has non-zero length) and returns it.
1089 *
1090 * @param a the array
1091 * @return the specified array
1092 * @throws NullPointerException if the specified array is null
1093 */
1094 public <T> T[] toArray(T[] a) {
1095 if (a.length > 0)
1096 a[0] = null;
1097 return a;
1098 }
1099
1100 /**
1101 * Always returns {@code "[]"}.
1102 * @return {@code "[]"}
1103 * @since 9
1104 */
1105 public String toString() {
1106 return "[]";
1107 }
1108
1109 /**
1110 * @throws UnsupportedOperationException {@inheritDoc}
1111 * @throws ClassCastException {@inheritDoc}
1112 * @throws NullPointerException {@inheritDoc}
1113 * @throws IllegalArgumentException {@inheritDoc}
1114 */
1115 public int drainTo(Collection<? super E> c) {
1116 Objects.requireNonNull(c);
1117 if (c == this)
1118 throw new IllegalArgumentException();
1119 int n = 0;
1120 for (E e; (e = poll()) != null; n++)
1121 c.add(e);
1122 return n;
1123 }
|