-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
156 lines (115 loc) · 4.04 KB
/
Solution.java
File metadata and controls
156 lines (115 loc) · 4.04 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//I have told you these things, that in me you may have peace. In the world you have oppression; but cheer up! I have overcome the world. (John 16:33)
package com.javarush.task.task17.task1713;
import java.util.*;
/*
Общий список
*/
public class Solution implements List<Long> {
private ArrayList<Long> original = new ArrayList<Long>();
public static void main(String[] args) {
}
@Override
public synchronized int size() {
return original.size();
}
@Override
public synchronized boolean isEmpty() {
return original.isEmpty();
}
@Override
public synchronized boolean contains(Object o) {
return original.contains(o);
}
@Override
public synchronized Iterator<Long> iterator() {
return original.iterator();
}
@Override
public synchronized Object[] toArray() {
return original.toArray();
}
@Override
public synchronized <T> T[] toArray(T[] a) {
return original.toArray(a);
}
@Override
public synchronized boolean add(Long aLong) {
return original.add(aLong);
}
@Override
public synchronized boolean remove(Object o) {
return original.remove(o);
}
@Override
public synchronized boolean containsAll(Collection<?> c) {
return original.containsAll(c);
}
@Override
public synchronized boolean addAll(Collection<? extends Long> c) {
return original.addAll(c);
}
@Override
public synchronized boolean addAll(int index, Collection<? extends Long> c) {
return original.addAll(index, c);
}
@Override
public synchronized boolean removeAll(Collection<?> c) {
return original.removeAll(c);
}
@Override
public synchronized boolean retainAll(Collection<?> c) {
return original.retainAll(c);
}
@Override
public synchronized void clear() {
original.clear();
}
@Override
public synchronized Long get(int index) {
return original.get(index);
}
@Override
public synchronized Long set(int index, Long element) {
return original.set(index, element);
}
@Override
public synchronized void add(int index, Long element) {
original.add(index, element);
}
@Override
public synchronized Long remove(int index) {
return original.remove(index);
}
@Override
public synchronized int indexOf(Object o) {
return original.indexOf(o);
}
@Override
public synchronized int lastIndexOf(Object o) {
return original.lastIndexOf(o);
}
@Override
public synchronized ListIterator<Long> listIterator() {
return original.listIterator();
}
@Override
public synchronized ListIterator<Long> listIterator(int index) {
return original.listIterator(index);
}
@Override
public synchronized List<Long> subList(int fromIndex, int toIndex) {
return original.subList(fromIndex, toIndex);
}
}
/*
Общий список
1. Изменить класс Solution так, чтобы он стал списком. (Необходимо реализовать интерфейс java.util.List).
2. Список Solution должен работать только с целыми числами Long.
3. Воспользуйтесь полем original.
4. Список будет использоваться нитями, поэтому позаботьтесь, чтобы все методы были синхронизированы.
Требования:
1. Класс Solution должен реализовывать интерфейс List.
2. Класс Solution должен содержать private поле original типа ArrayList.
3. Все переопределенные методы интерфейса List должны делегировать полномочия методам объекта original.
4. Все методы класса Solution, кроме метода main, должны быть синхронизированы.
*/