57 |
|
|
58 |
|
/** Doubly-linked list node class */ |
59 |
|
static final class Node<E> { |
60 |
< |
E item; |
60 |
> |
E item; |
61 |
|
Node<E> prev; |
62 |
|
Node<E> next; |
63 |
|
Node(E x, Node<E> p, Node<E> n) { |
299 |
|
public boolean offerFirst(E e, long timeout, TimeUnit unit) |
300 |
|
throws InterruptedException { |
301 |
|
if (e == null) throw new NullPointerException(); |
302 |
< |
long nanos = unit.toNanos(timeout); |
302 |
> |
long nanos = unit.toNanos(timeout); |
303 |
|
lock.lockInterruptibly(); |
304 |
|
try { |
305 |
|
for (;;) { |
321 |
|
public boolean offerLast(E e, long timeout, TimeUnit unit) |
322 |
|
throws InterruptedException { |
323 |
|
if (e == null) throw new NullPointerException(); |
324 |
< |
long nanos = unit.toNanos(timeout); |
324 |
> |
long nanos = unit.toNanos(timeout); |
325 |
|
lock.lockInterruptibly(); |
326 |
|
try { |
327 |
|
for (;;) { |
398 |
|
|
399 |
|
public E pollFirst(long timeout, TimeUnit unit) |
400 |
|
throws InterruptedException { |
401 |
< |
long nanos = unit.toNanos(timeout); |
401 |
> |
long nanos = unit.toNanos(timeout); |
402 |
|
lock.lockInterruptibly(); |
403 |
|
try { |
404 |
|
for (;;) { |
416 |
|
|
417 |
|
public E pollLast(long timeout, TimeUnit unit) |
418 |
|
throws InterruptedException { |
419 |
< |
long nanos = unit.toNanos(timeout); |
419 |
> |
long nanos = unit.toNanos(timeout); |
420 |
|
lock.lockInterruptibly(); |
421 |
|
try { |
422 |
|
for (;;) { |
514 |
|
* @throws NullPointerException if the specified element is null |
515 |
|
*/ |
516 |
|
public boolean add(E e) { |
517 |
< |
addLast(e); |
518 |
< |
return true; |
517 |
> |
addLast(e); |
518 |
> |
return true; |
519 |
|
} |
520 |
|
|
521 |
|
/** |
522 |
|
* @throws NullPointerException if the specified element is null |
523 |
|
*/ |
524 |
|
public boolean offer(E e) { |
525 |
< |
return offerLast(e); |
525 |
> |
return offerLast(e); |
526 |
|
} |
527 |
|
|
528 |
|
/** |
530 |
|
* @throws InterruptedException {@inheritDoc} |
531 |
|
*/ |
532 |
|
public void put(E e) throws InterruptedException { |
533 |
< |
putLast(e); |
533 |
> |
putLast(e); |
534 |
|
} |
535 |
|
|
536 |
|
/** |
539 |
|
*/ |
540 |
|
public boolean offer(E e, long timeout, TimeUnit unit) |
541 |
|
throws InterruptedException { |
542 |
< |
return offerLast(e, timeout, unit); |
542 |
> |
return offerLast(e, timeout, unit); |
543 |
|
} |
544 |
|
|
545 |
|
/** |
553 |
|
* @throws NoSuchElementException if this deque is empty |
554 |
|
*/ |
555 |
|
public E remove() { |
556 |
< |
return removeFirst(); |
556 |
> |
return removeFirst(); |
557 |
|
} |
558 |
|
|
559 |
|
public E poll() { |
560 |
< |
return pollFirst(); |
560 |
> |
return pollFirst(); |
561 |
|
} |
562 |
|
|
563 |
|
public E take() throws InterruptedException { |
564 |
< |
return takeFirst(); |
564 |
> |
return takeFirst(); |
565 |
|
} |
566 |
|
|
567 |
|
public E poll(long timeout, TimeUnit unit) throws InterruptedException { |
568 |
< |
return pollFirst(timeout, unit); |
568 |
> |
return pollFirst(timeout, unit); |
569 |
|
} |
570 |
|
|
571 |
|
/** |
579 |
|
* @throws NoSuchElementException if this deque is empty |
580 |
|
*/ |
581 |
|
public E element() { |
582 |
< |
return getFirst(); |
582 |
> |
return getFirst(); |
583 |
|
} |
584 |
|
|
585 |
|
public E peek() { |
586 |
< |
return peekFirst(); |
586 |
> |
return peekFirst(); |
587 |
|
} |
588 |
|
|
589 |
|
/** |
668 |
|
* @throws NullPointerException {@inheritDoc} |
669 |
|
*/ |
670 |
|
public void push(E e) { |
671 |
< |
addFirst(e); |
671 |
> |
addFirst(e); |
672 |
|
} |
673 |
|
|
674 |
|
/** |
675 |
|
* @throws NoSuchElementException {@inheritDoc} |
676 |
|
*/ |
677 |
|
public E pop() { |
678 |
< |
return removeFirst(); |
678 |
> |
return removeFirst(); |
679 |
|
} |
680 |
|
|
681 |
|
// Collection methods |
695 |
|
* @return <tt>true</tt> if this deque changed as a result of the call |
696 |
|
*/ |
697 |
|
public boolean remove(Object o) { |
698 |
< |
return removeFirstOccurrence(o); |
698 |
> |
return removeFirstOccurrence(o); |
699 |
|
} |
700 |
|
|
701 |
|
/** |