1006 |
1006 |
1007 /** |
1007 /** |
1008 * Returns an iterator over the elements in this deque in proper sequence. |
1008 * Returns an iterator over the elements in this deque in proper sequence. |
1009 * The elements will be returned in order from first (head) to last (tail). |
1009 * The elements will be returned in order from first (head) to last (tail). |
1010 * |
1010 * |
1011 * <p>The returned iterator is a "weakly consistent" iterator that |
1011 * <p>The returned iterator is |
1012 * will never throw {@link java.util.ConcurrentModificationException |
1012 * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. |
1013 * ConcurrentModificationException}, and guarantees to traverse |
|
1014 * elements as they existed upon construction of the iterator, and |
|
1015 * may (but is not guaranteed to) reflect any modifications |
|
1016 * subsequent to construction. |
|
1017 * |
1013 * |
1018 * @return an iterator over the elements in this deque in proper sequence |
1014 * @return an iterator over the elements in this deque in proper sequence |
1019 */ |
1015 */ |
1020 public Iterator<E> iterator() { |
1016 public Iterator<E> iterator() { |
1021 return new Itr(); |
1017 return new Itr(); |
1024 /** |
1020 /** |
1025 * Returns an iterator over the elements in this deque in reverse |
1021 * Returns an iterator over the elements in this deque in reverse |
1026 * sequential order. The elements will be returned in order from |
1022 * sequential order. The elements will be returned in order from |
1027 * last (tail) to first (head). |
1023 * last (tail) to first (head). |
1028 * |
1024 * |
1029 * <p>The returned iterator is a "weakly consistent" iterator that |
1025 * <p>The returned iterator is |
1030 * will never throw {@link java.util.ConcurrentModificationException |
1026 * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. |
1031 * ConcurrentModificationException}, and guarantees to traverse |
|
1032 * elements as they existed upon construction of the iterator, and |
|
1033 * may (but is not guaranteed to) reflect any modifications |
|
1034 * subsequent to construction. |
|
1035 * |
1027 * |
1036 * @return an iterator over the elements in this deque in reverse order |
1028 * @return an iterator over the elements in this deque in reverse order |
1037 */ |
1029 */ |
1038 public Iterator<E> descendingIterator() { |
1030 public Iterator<E> descendingIterator() { |
1039 return new DescendingItr(); |
1031 return new DescendingItr(); |
1268 return Spliterator.ORDERED | Spliterator.NONNULL | |
1260 return Spliterator.ORDERED | Spliterator.NONNULL | |
1269 Spliterator.CONCURRENT; |
1261 Spliterator.CONCURRENT; |
1270 } |
1262 } |
1271 } |
1263 } |
1272 |
1264 |
|
1265 /** |
|
1266 * Returns a {@link Spliterator} over the elements in this deque. |
|
1267 * |
|
1268 * <p>The returned spliterator is |
|
1269 * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. |
|
1270 * |
|
1271 * <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT}, |
|
1272 * {@link Spliterator#ORDERED}, and {@link Spliterator#NONNULL}. |
|
1273 * |
|
1274 * @implNote |
|
1275 * The {@code Spliterator} implements {@code trySplit} to permit limited |
|
1276 * parallelism. |
|
1277 * |
|
1278 * @return a {@code Spliterator} over the elements in this deque |
|
1279 * @since 1.8 |
|
1280 */ |
1273 public Spliterator<E> spliterator() { |
1281 public Spliterator<E> spliterator() { |
1274 return new LBDSpliterator<E>(this); |
1282 return new LBDSpliterator<E>(this); |
1275 } |
1283 } |
1276 |
1284 |
1277 /** |
1285 /** |
1278 * Saves this deque to a stream (that is, serializes it). |
1286 * Saves this deque to a stream (that is, serializes it). |
1279 * |
1287 * |
|
1288 * @param s the stream |
|
1289 * @throws java.io.IOException if an I/O error occurs |
1280 * @serialData The capacity (int), followed by elements (each an |
1290 * @serialData The capacity (int), followed by elements (each an |
1281 * {@code Object}) in the proper order, followed by a null |
1291 * {@code Object}) in the proper order, followed by a null |
1282 */ |
1292 */ |
1283 private void writeObject(java.io.ObjectOutputStream s) |
1293 private void writeObject(java.io.ObjectOutputStream s) |
1284 throws java.io.IOException { |
1294 throws java.io.IOException { |
1297 } |
1307 } |
1298 } |
1308 } |
1299 |
1309 |
1300 /** |
1310 /** |
1301 * Reconstitutes this deque from a stream (that is, deserializes it). |
1311 * Reconstitutes this deque from a stream (that is, deserializes it). |
|
1312 * @param s the stream |
|
1313 * @throws ClassNotFoundException if the class of a serialized object |
|
1314 * could not be found |
|
1315 * @throws java.io.IOException if an I/O error occurs |
1302 */ |
1316 */ |
1303 private void readObject(java.io.ObjectInputStream s) |
1317 private void readObject(java.io.ObjectInputStream s) |
1304 throws java.io.IOException, ClassNotFoundException { |
1318 throws java.io.IOException, ClassNotFoundException { |
1305 s.defaultReadObject(); |
1319 s.defaultReadObject(); |
1306 count = 0; |
1320 count = 0; |