Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions src/ArrayStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
public class ArrayStorage {
Resume[] storage = new Resume[10000];

private static int size = 0;
private int size = 0;

void clear() {
for (int i = 0; i < size; i++) {
Expand All @@ -21,7 +21,6 @@ void save(Resume r) {
}

Resume get(String uuid) {
int size = size();
for (int i = 0; i < size; i++) {
if (uuid.equals(storage[i].toString())) {
return storage[i];
Expand All @@ -32,28 +31,27 @@ Resume get(String uuid) {

void delete(String uuid) {
int deletedPosition = -1;
if (get(uuid) != null) {
for (int i = 0; i < size; i++) {
if (uuid.equals(storage[i].toString())) {
deletedPosition = i;
}
for (int i = 0; i < size; i++) {
if (uuid.equals(storage[i].toString())) {
deletedPosition = i;
size--;
break;
}
for (int i = deletedPosition; i < size; i++) {
if (i < storage.length - 1) {
storage[i] = storage[i + 1];
} else {
storage[i] = null;
}
}
for (int i = deletedPosition; i < size; i++) {
if (i < storage.length - 1) {
storage[i] = storage[i + 1];
} else {
storage[i] = null;
}
size--;
}
}

/**
* @return array, contains only Resumes in storage (without null)
*/
Resume[] getAll() {
Resume[] allResume = new Resume[size()];
Resume[] allResume = new Resume[size];
if (size > 0) {
System.arraycopy(storage, 0, allResume, 0, size);
}
Expand Down