Skip to content
Open
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
54cb720
HW1
YaDokaYa Oct 17, 2024
1aba60b
HW1
YaDokaYa Oct 17, 2024
4e444d6
HW1:fix delete null, rename storageAll->resumes, corrected delete()
YaDokaYa Oct 22, 2024
09b08b7
HW2: sorted by packages
YaDokaYa Nov 22, 2024
de07681
HW2: update
YaDokaYa Nov 26, 2024
5592ef7
HW2: clear, save, get, delete, getAll,desiredIndex
YaDokaYa Nov 26, 2024
d416a6b
HW2: finally
YaDokaYa Nov 29, 2024
b092f4a
HW2: finally with static class members
YaDokaYa Dec 3, 2024
e5c08b7
HW3: introduce interface
YaDokaYa Dec 3, 2024
ee84f2a
HW3: abstract storage & sorted storage
YaDokaYa Dec 3, 2024
e06f72b
HW3: abstract storage & sorted storage & array storage
YaDokaYa Dec 5, 2024
ed69d01
HW3: templateMethod & save
YaDokaYa Dec 7, 2024
7934f8d
HW3: increaseSize() & protected void reductionSize()
YaDokaYa Dec 12, 2024
83fedb6
HW3: template method
YaDokaYa Dec 12, 2024
00efee7
HW3: finally with removeLastElement()
YaDokaYa Dec 16, 2024
e8aa68f
HW4: exception
YaDokaYa Jan 21, 2025
4db0eba
HW4: begin test
YaDokaYa Jan 21, 2025
e90cd9d
HW4: method get()
YaDokaYa Jan 21, 2025
8e7013e
HW4: method toString through reflection
YaDokaYa Jan 23, 2025
800f91c
HW4: tests
YaDokaYa Jan 23, 2025
b701371
HW4: correction of methods
YaDokaYa Jan 28, 2025
ed0b2cb
HW4: error testStorageOverflow
YaDokaYa Jan 30, 2025
d6963a3
HW4: testStorageOverflow
YaDokaYa Feb 7, 2025
081e3ba
HW4: MainReflection_HW
YaDokaYa Feb 7, 2025
828d01f
HW4: finally
YaDokaYa Feb 7, 2025
2abe819
HW5: begin
YaDokaYa Feb 11, 2025
c9519ee
HW5: static initializer block
YaDokaYa Feb 11, 2025
7770e8c
HW5: final Storage storage
YaDokaYa Feb 11, 2025
a7b68f4
HW5: class AbstractStorage
YaDokaYa Feb 18, 2025
3f05c40
HW5: method exist()&&doUpdate()
YaDokaYa Feb 18, 2025
cbdb919
HW5: method doSave()&&save()
YaDokaYa Feb 18, 2025
0d26281
HW5: method doGet()&&get()
YaDokaYa Feb 18, 2025
a8d41c7
HW5: method doDelete()&&delete()
YaDokaYa Feb 18, 2025
16b70f0
HW5: delete clear(), getAll(), size()
YaDokaYa Feb 21, 2025
643a355
HW5: getSearchKey()&&isExisting()
YaDokaYa Feb 25, 2025
5fb2322
HW5: getExistingSearchKey()
YaDokaYa Feb 25, 2025
54d23ba
HW5: delete save() from AbstractArrayStorage && SortedArrayStorage
YaDokaYa Feb 25, 2025
85982b7
HW5: MapStorage && MapStorageTest
YaDokaYa Feb 27, 2025
1890dfd
HW5: isExisting in AbstractStorage
YaDokaYa Mar 13, 2025
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
Prev Previous commit
Next Next commit
HW2: finally
  • Loading branch information
YaDokaYa committed Nov 29, 2024
commit d416a6bc1bf20e25624252d2ff41aee3a368e11e
30 changes: 16 additions & 14 deletions src/com/urise/webapp/storage/ArrayStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@
* Array based storage for Resumes
*/
public class ArrayStorage {
private final Resume[] storage = new Resume[10000];
private final Resume[] STORAGE_LIMIT = new Resume[10000];
private int size = 0;

public void clear() {
Arrays.fill(storage, 0, size, null);
Arrays.fill(STORAGE_LIMIT, 0, size, null);
size = 0;
System.out.println("\nThe array was successfully cleared");
}

public void update(Resume r) {
int index = desiredIndex(r.getUuid());
int index = findIndex(r.getUuid());
if (index >= 0) {
storage[index].setUuid(r.getUuid());
STORAGE_LIMIT[index].setUuid(r.getUuid());
System.out.println("\nElement " + r + " successfully update");
} else {
System.out.println("\nERROR: Element " + r + " not found");
}
}

public void save(Resume r) {
int index = desiredIndex(r.getUuid());
if (index < 0 && size < storage.length) {
storage[size] = r;
int index = findIndex(r.getUuid());
if (index < 0 && size < STORAGE_LIMIT.length) {
STORAGE_LIMIT[size] = r;
size++;
System.out.println("Element " + r + " successfully saved to array");
} else {
Expand All @@ -39,17 +39,18 @@ public void save(Resume r) {
}

public Resume get(String uuid) {
int index = desiredIndex(uuid);
int index = findIndex(uuid);
if (index >= 0) {
return storage[index];
return STORAGE_LIMIT[index];
}
System.out.println("\nElement " + uuid + " not found");
return null;
}

public void delete(String uuid) {
int index = desiredIndex(uuid);
int index = findIndex(uuid);
if (index >= 0) {
storage[index] = storage[size - 1];
STORAGE_LIMIT[index] = STORAGE_LIMIT[size - 1];
size--;
System.out.println("\nElement " + uuid + " successfully deleted");
return;
Expand All @@ -61,19 +62,20 @@ public void delete(String uuid) {
* @return array, contains only Resumes in storage (without null)
*/
public Resume[] getAll() {
return Arrays.copyOf(storage, size);
return Arrays.copyOf(STORAGE_LIMIT, size);
}

public int size() {
return size;
}

public int desiredIndex(String uuid) {
public int findIndex(String uuid) {
for (int i = 0; i < size; i++) {
if (storage[i].getUuid().equals(uuid)) {
if (STORAGE_LIMIT[i].getUuid().equals(uuid)) {
return i;
}
}
return -1;
}
}