533 |
|
} |
534 |
|
|
535 |
|
/** |
536 |
+ |
* Returns {@code true} if this queue contains the specified element. |
537 |
+ |
* More formally, returns {@code true} if and only if this queue contains |
538 |
+ |
* at least one element {@code e} such that {@code o.equals(e)}. |
539 |
+ |
* |
540 |
+ |
* @param o object to be checked for containment in this queue |
541 |
+ |
* @return {@code true} if this queue contains the specified element |
542 |
+ |
*/ |
543 |
+ |
public boolean contains(Object o) { |
544 |
+ |
if (o == null) return false; |
545 |
+ |
fullyLock(); |
546 |
+ |
try { |
547 |
+ |
for (Node<E> p = head.next; p != null; p = p.next) |
548 |
+ |
if (o.equals(p.item)) |
549 |
+ |
return true; |
550 |
+ |
return false; |
551 |
+ |
} finally { |
552 |
+ |
fullyUnlock(); |
553 |
+ |
} |
554 |
+ |
} |
555 |
+ |
|
556 |
+ |
/** |
557 |
|
* Returns an array containing all of the elements in this queue, in |
558 |
|
* proper sequence. |
559 |
|
* |