-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
ConcurrentQueueList.java
68 lines (56 loc) · 1.45 KB
/
ConcurrentQueueList.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package nallar.collections;
import java.util.*;
import java.util.concurrent.*;
@SuppressWarnings("ConstantConditions")
public class ConcurrentQueueList<T> extends ConcurrentLinkedQueue<T> implements List<T> {
@Override
public boolean addAll(Collection<? extends T> c) {
return c == this || super.addAll(c);
}
@Override
public boolean addAll(int index, Collection c) {
throw new UnsupportedOperationException();
}
@Override
public T get(int index) {
if (index == 0) {
return this.peek();
}
throw new UnsupportedOperationException();
}
@Override
public T set(int index, Object element) {
throw new UnsupportedOperationException();
}
@Override
public void add(int index, Object element) {
throw new UnsupportedOperationException();
}
@Override
public T remove(int index) {
if (index == 0) {
return this.poll();
}
throw new UnsupportedOperationException();
}
@Override
public int indexOf(Object o) {
throw new UnsupportedOperationException();
}
@Override
public int lastIndexOf(Object o) {
throw new UnsupportedOperationException();
}
@Override
public ListIterator<T> listIterator() {
throw new UnsupportedOperationException();
}
@Override
public ListIterator<T> listIterator(int index) {
throw new UnsupportedOperationException();
}
@Override
public List<T> subList(int fromIndex, int toIndex) {
throw new UnsupportedOperationException();
}
}