Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
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
60 changes: 57 additions & 3 deletions 60 src/ArrayStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,80 @@ public class ArrayStorage {
Resume[] storage = new Resume[10000];

void clear() {
for (int i = 0; i < storage.length; i++) {

//Дошли до конца заполненных данных - прервем цикл
if (storage[i] == null){
break;
}

storage[i] = null;
}
}

void save(Resume r) {

//Нужно найти свободную позицию если таковой не нашлось то будет Исключение.
for (int i = 0; i < storage.length; i++) {
if (storage[i] == null){
storage[i] = r;
return;
}
}
throw new ArrayIndexOutOfBoundsException("Maximum storage value reached!");
}

Resume get(String uuid) {
return null;

Resume findResume = null;
for (int i = 0; i < storage.length; i++) {
if (storage[i] != null) {
if (storage[i].uuid.equals(uuid)) {
findResume = storage[i];
break;
}
}
}
return findResume;
}

void delete(String uuid) {

//Поиск по всем ЗАПОЛНЕННЫМ элементам - используем size
for (int i = 0; i < size(); i++) {

if (storage[i].uuid.equals(uuid)) {

//Заполним пустоту последним существующим элементом
storage[i] = storage[size()-1];

//И затрем значение послднего - т.к. переместили его в позицию удаленного элемента
storage[size()-1] = null;
}

}
}

/**
* @return array, contains only Resumes in storage (without null)
*/
Resume[] getAll() {
return new Resume[0];
Resume[] resumes = new Resume[size()];

for (int i = 0; i < resumes.length; i++) {
resumes[i] = storage[i];
}

return resumes;
}

int size() {
return 0;

for (int i = 0; i < storage.length; i++) {
if (storage[i] == null){
return i;
}
}
return storage.length;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.