327 /** 328 * Retrieves, but does not remove, the first element of this deque, 329 * or returns {@code null} if this deque is empty. 330 * 331 * @return the head of this deque, or {@code null} if this deque is empty 332 */ 333 E peekFirst(); 334 335 /** 336 * Retrieves, but does not remove, the last element of this deque, 337 * or returns {@code null} if this deque is empty. 338 * 339 * @return the tail of this deque, or {@code null} if this deque is empty 340 */ 341 E peekLast(); 342 343 /** 344 * Removes the first occurrence of the specified element from this deque. 345 * If the deque does not contain the element, it is unchanged. 346 * More formally, removes the first element {@code e} such that 347 * <tt>(o==null ? e==null : o.equals(e))</tt> 348 * (if such an element exists). 349 * Returns {@code true} if this deque contained the specified element 350 * (or equivalently, if this deque changed as a result of the call). 351 * 352 * @param o element to be removed from this deque, if present 353 * @return {@code true} if an element was removed as a result of this call 354 * @throws ClassCastException if the class of the specified element 355 * is incompatible with this deque 356 * (<a href="Collection.html#optional-restrictions">optional</a>) 357 * @throws NullPointerException if the specified element is null and this 358 * deque does not permit null elements 359 * (<a href="Collection.html#optional-restrictions">optional</a>) 360 */ 361 boolean removeFirstOccurrence(Object o); 362 363 /** 364 * Removes the last occurrence of the specified element from this deque. 365 * If the deque does not contain the element, it is unchanged. 366 * More formally, removes the last element {@code e} such that 367 * <tt>(o==null ? e==null : o.equals(e))</tt> 368 * (if such an element exists). 369 * Returns {@code true} if this deque contained the specified element 370 * (or equivalently, if this deque changed as a result of the call). 371 * 372 * @param o element to be removed from this deque, if present 373 * @return {@code true} if an element was removed as a result of this call 374 * @throws ClassCastException if the class of the specified element 375 * is incompatible with this deque 376 * (<a href="Collection.html#optional-restrictions">optional</a>) 377 * @throws NullPointerException if the specified element is null and this 378 * deque does not permit null elements 379 * (<a href="Collection.html#optional-restrictions">optional</a>) 380 */ 381 boolean removeLastOccurrence(Object o); 382 383 // *** Queue methods *** 384 385 /** 386 * Inserts the specified element into the queue represented by this deque 387 * (in other words, at the tail of this deque) if it is possible to do so 504 505 /** 506 * Pops an element from the stack represented by this deque. In other 507 * words, removes and returns the first element of this deque. 508 * 509 * <p>This method is equivalent to {@link #removeFirst()}. 510 * 511 * @return the element at the front of this deque (which is the top 512 * of the stack represented by this deque) 513 * @throws NoSuchElementException if this deque is empty 514 */ 515 E pop(); 516 517 518 // *** Collection methods *** 519 520 /** 521 * Removes the first occurrence of the specified element from this deque. 522 * If the deque does not contain the element, it is unchanged. 523 * More formally, removes the first element {@code e} such that 524 * <tt>(o==null ? e==null : o.equals(e))</tt> 525 * (if such an element exists). 526 * Returns {@code true} if this deque contained the specified element 527 * (or equivalently, if this deque changed as a result of the call). 528 * 529 * <p>This method is equivalent to {@link #removeFirstOccurrence(Object)}. 530 * 531 * @param o element to be removed from this deque, if present 532 * @return {@code true} if an element was removed as a result of this call 533 * @throws ClassCastException if the class of the specified element 534 * is incompatible with this deque 535 * (<a href="Collection.html#optional-restrictions">optional</a>) 536 * @throws NullPointerException if the specified element is null and this 537 * deque does not permit null elements 538 * (<a href="Collection.html#optional-restrictions">optional</a>) 539 */ 540 boolean remove(Object o); 541 542 /** 543 * Returns {@code true} if this deque contains the specified element. 544 * More formally, returns {@code true} if and only if this deque contains 545 * at least one element {@code e} such that 546 * <tt>(o==null ? e==null : o.equals(e))</tt>. 547 * 548 * @param o element whose presence in this deque is to be tested 549 * @return {@code true} if this deque contains the specified element 550 * @throws ClassCastException if the type of the specified element 551 * is incompatible with this deque 552 * (<a href="Collection.html#optional-restrictions">optional</a>) 553 * @throws NullPointerException if the specified element is null and this 554 * deque does not permit null elements 555 * (<a href="Collection.html#optional-restrictions">optional</a>) 556 */ 557 boolean contains(Object o); 558 559 /** 560 * Returns the number of elements in this deque. 561 * 562 * @return the number of elements in this deque 563 */ 564 public int size(); 565 566 /** | 327 /** 328 * Retrieves, but does not remove, the first element of this deque, 329 * or returns {@code null} if this deque is empty. 330 * 331 * @return the head of this deque, or {@code null} if this deque is empty 332 */ 333 E peekFirst(); 334 335 /** 336 * Retrieves, but does not remove, the last element of this deque, 337 * or returns {@code null} if this deque is empty. 338 * 339 * @return the tail of this deque, or {@code null} if this deque is empty 340 */ 341 E peekLast(); 342 343 /** 344 * Removes the first occurrence of the specified element from this deque. 345 * If the deque does not contain the element, it is unchanged. 346 * More formally, removes the first element {@code e} such that 347 * <code>(o==null ? e==null : o.equals(e))</code> 348 * (if such an element exists). 349 * Returns {@code true} if this deque contained the specified element 350 * (or equivalently, if this deque changed as a result of the call). 351 * 352 * @param o element to be removed from this deque, if present 353 * @return {@code true} if an element was removed as a result of this call 354 * @throws ClassCastException if the class of the specified element 355 * is incompatible with this deque 356 * (<a href="Collection.html#optional-restrictions">optional</a>) 357 * @throws NullPointerException if the specified element is null and this 358 * deque does not permit null elements 359 * (<a href="Collection.html#optional-restrictions">optional</a>) 360 */ 361 boolean removeFirstOccurrence(Object o); 362 363 /** 364 * Removes the last occurrence of the specified element from this deque. 365 * If the deque does not contain the element, it is unchanged. 366 * More formally, removes the last element {@code e} such that 367 * <code>(o==null ? e==null : o.equals(e))</code> 368 * (if such an element exists). 369 * Returns {@code true} if this deque contained the specified element 370 * (or equivalently, if this deque changed as a result of the call). 371 * 372 * @param o element to be removed from this deque, if present 373 * @return {@code true} if an element was removed as a result of this call 374 * @throws ClassCastException if the class of the specified element 375 * is incompatible with this deque 376 * (<a href="Collection.html#optional-restrictions">optional</a>) 377 * @throws NullPointerException if the specified element is null and this 378 * deque does not permit null elements 379 * (<a href="Collection.html#optional-restrictions">optional</a>) 380 */ 381 boolean removeLastOccurrence(Object o); 382 383 // *** Queue methods *** 384 385 /** 386 * Inserts the specified element into the queue represented by this deque 387 * (in other words, at the tail of this deque) if it is possible to do so 504 505 /** 506 * Pops an element from the stack represented by this deque. In other 507 * words, removes and returns the first element of this deque. 508 * 509 * <p>This method is equivalent to {@link #removeFirst()}. 510 * 511 * @return the element at the front of this deque (which is the top 512 * of the stack represented by this deque) 513 * @throws NoSuchElementException if this deque is empty 514 */ 515 E pop(); 516 517 518 // *** Collection methods *** 519 520 /** 521 * Removes the first occurrence of the specified element from this deque. 522 * If the deque does not contain the element, it is unchanged. 523 * More formally, removes the first element {@code e} such that 524 * <code>(o==null ? e==null : o.equals(e))</code> 525 * (if such an element exists). 526 * Returns {@code true} if this deque contained the specified element 527 * (or equivalently, if this deque changed as a result of the call). 528 * 529 * <p>This method is equivalent to {@link #removeFirstOccurrence(Object)}. 530 * 531 * @param o element to be removed from this deque, if present 532 * @return {@code true} if an element was removed as a result of this call 533 * @throws ClassCastException if the class of the specified element 534 * is incompatible with this deque 535 * (<a href="Collection.html#optional-restrictions">optional</a>) 536 * @throws NullPointerException if the specified element is null and this 537 * deque does not permit null elements 538 * (<a href="Collection.html#optional-restrictions">optional</a>) 539 */ 540 boolean remove(Object o); 541 542 /** 543 * Returns {@code true} if this deque contains the specified element. 544 * More formally, returns {@code true} if and only if this deque contains 545 * at least one element {@code e} such that 546 * <code>(o==null ? e==null : o.equals(e))</code>. 547 * 548 * @param o element whose presence in this deque is to be tested 549 * @return {@code true} if this deque contains the specified element 550 * @throws ClassCastException if the type of the specified element 551 * is incompatible with this deque 552 * (<a href="Collection.html#optional-restrictions">optional</a>) 553 * @throws NullPointerException if the specified element is null and this 554 * deque does not permit null elements 555 * (<a href="Collection.html#optional-restrictions">optional</a>) 556 */ 557 boolean contains(Object o); 558 559 /** 560 * Returns the number of elements in this deque. 561 * 562 * @return the number of elements in this deque 563 */ 564 public int size(); 565 566 /** |