-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayStorage.java
More file actions
37 lines (27 loc) · 830 Bytes
/
Copy pathArrayStorage.java
File metadata and controls
37 lines (27 loc) · 830 Bytes
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
package storage;
import exception.StorageException;
import model.Resume;
public class ArrayStorage extends AbstractArrayStorage {
@Override
protected void deleteAndReplace(Object searchKey) {
//add last element to deleted element
storage[(Integer) searchKey] = storage[size - 1];
}
@Override
protected void insertResume(Resume r, Object searchKey) {
if(size() == MAX_CAPACITY) {
throw new StorageException(r.getUuid(), "Storage is overflow");
}
storage[size] = r;
size++;
}
protected Object getSearchKey(String uuid) {
for(int i = 0; i < size; i++){
String uuidCurrent = storage[i].getUuid();
if(uuidCurrent.equals(uuid)){
return i;
}
}
return -1;
}
}