315 |
|
* @return {@code true} if the deque contained the specified element |
316 |
|
*/ |
317 |
|
public boolean removeFirstOccurrence(Object o) { |
318 |
< |
if (o == null) |
319 |
< |
return false; |
320 |
< |
int mask = elements.length - 1; |
321 |
< |
int i = head; |
322 |
< |
Object x; |
323 |
< |
while ( (x = elements[i]) != null) { |
324 |
< |
if (o.equals(x)) { |
325 |
< |
delete(i); |
326 |
< |
return true; |
318 |
> |
if (o != null) { |
319 |
> |
int mask = elements.length - 1; |
320 |
> |
int i = head; |
321 |
> |
Object x; |
322 |
> |
while ( (x = elements[i]) != null) { |
323 |
> |
if (o.equals(x)) { |
324 |
> |
delete(i); |
325 |
> |
return true; |
326 |
> |
} |
327 |
> |
i = (i + 1) & mask; |
328 |
|
} |
328 |
– |
i = (i + 1) & mask; |
329 |
|
} |
330 |
|
return false; |
331 |
|
} |
658 |
|
* @return {@code true} if this deque contains the specified element |
659 |
|
*/ |
660 |
|
public boolean contains(Object o) { |
661 |
< |
if (o == null) |
662 |
< |
return false; |
663 |
< |
int mask = elements.length - 1; |
664 |
< |
int i = head; |
665 |
< |
Object x; |
666 |
< |
while ( (x = elements[i]) != null) { |
667 |
< |
if (o.equals(x)) |
668 |
< |
return true; |
669 |
< |
i = (i + 1) & mask; |
661 |
> |
if (o != null) { |
662 |
> |
int mask = elements.length - 1; |
663 |
> |
int i = head; |
664 |
> |
Object x; |
665 |
> |
while ( (x = elements[i]) != null) { |
666 |
> |
if (o.equals(x)) |
667 |
> |
return true; |
668 |
> |
i = (i + 1) & mask; |
669 |
> |
} |
670 |
|
} |
671 |
|
return false; |
672 |
|
} |