-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractArrayStorage.java
More file actions
55 lines (39 loc) · 1.19 KB
/
Copy pathAbstractArrayStorage.java
File metadata and controls
55 lines (39 loc) · 1.19 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
package storage;
import model.Resume;
import java.util.Arrays;
import java.util.List;
public abstract class AbstractArrayStorage extends AbstractStorage{
protected static final int MAX_CAPACITY = 10000;
protected int size = 0;
protected Resume[] storage = new Resume[MAX_CAPACITY];
public void clear(){
Arrays.fill(storage, 0, size, null);
size = 0;
}
public int size() {
return size;
}
@Override
protected void deleteFromStorage(Object searchKey) {
deleteAndReplace(searchKey);
storage[size - 1] = null;
size--;
}
protected Resume getResumeFromStorage(Object searchKey){
return storage[(Integer) searchKey];
}
@Override
protected void updateResume(Resume r, Object searchKey) {
storage[(Integer) searchKey] = r;
}
@Override
protected List<Resume> getCopyResumeList() {
List<Resume> copyStorage =Arrays.asList(Arrays.copyOfRange(storage, 0, size));
return copyStorage;
}
@Override
protected boolean isExist(Object searchKey) {
return (Integer) searchKey >=0;
}
protected abstract void deleteAndReplace(Object searchKey);
}