-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayStorage.java
More file actions
50 lines (43 loc) · 1.02 KB
/
Copy pathArrayStorage.java
File metadata and controls
50 lines (43 loc) · 1.02 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
import java.util.Arrays;
/**
* Array based storage for Resumes
*/
public class ArrayStorage {
Resume[] storage = new Resume[10000];
private int size;
void clear() {
Arrays.fill(storage, 0, size, null);
size = 0;
}
void save(Resume r) {
storage[size] = r;
size++;
}
Resume get(String uuid) {
for (int i = 0; i < size; i++) {
if (storage[i].toString().equals(uuid)) {
return storage[i];
}
}
return null;
}
void delete(String uuid) {
for (int i = 0; i < size; i++) {
if (storage[i].toString().equals(uuid)) {
storage[i] = storage[size -1];
storage[size - 1] = null;
size--;
break;
}
}
}
/**
* @return array, contains only Resumes in storage (without null)
*/
Resume[] getAll() {
return Arrays.copyOf(storage, size);
}
int size() {
return size;
}
}