MCPcopy Create free account
hub / github.com/ReadyTalk/avian / AbstractQueue

Class AbstractQueue

classpath/java/util/AbstractQueue.java:13–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11package java.util;
12
13public abstract class AbstractQueue<T> extends AbstractCollection<T> implements Queue<T> {
14
15 protected AbstractQueue() {
16 super();
17 }
18
19 @Override
20 public boolean add(T element) {
21 if (offer(element)) {
22 return true;
23 } else {
24 throw new IllegalStateException();
25 }
26 }
27
28 @Override
29 public boolean addAll(Collection <? extends T> collection) {
30 if (collection == null) {
31 throw new NullPointerException();
32 }
33
34 for (T element : collection) {
35 add(element);
36 }
37
38 return true;
39 }
40
41 @Override
42 public void clear() {
43 while (size() > 0) {
44 poll();
45 }
46 }
47
48 @Override
49 public T element() {
50 T result = peek();
51 if (result == null) {
52 throw new NoSuchElementException();
53 } else {
54 return result;
55 }
56 }
57
58 @Override
59 public T remove() {
60 T result = poll();
61 if (result == null) {
62 throw new NoSuchElementException();
63 } else {
64 return result;
65 }
66 }
67}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected