Skip to content

Commit c9675bc

Browse files
committed
delete all inline
1 parent d1ea56c commit c9675bc

2 files changed

Lines changed: 19 additions & 15 deletions

File tree

‎src/com/urise/webapp/storage/ArrayStorage.java‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import java.util.Arrays;
66

77
public class ArrayStorage implements Storage{
8-
private static final int storageSize = 10000;
9-
Resume[] storage = new Resume[storageSize];
8+
private static final int storage_limit = 10000;
9+
private Resume[] storage = new Resume[storage_limit];
1010
int size = 0;
1111

1212
public void clear() {
@@ -15,37 +15,41 @@ public void clear() {
1515
}
1616

1717
public void update(Resume r) {
18-
if (getIndex(r.getUuid()) == -1) {
18+
int index = getIndex(r.getUuid());
19+
if (index == -1) {
1920
System.out.println("not find resume " + r.getUuid());
2021
} else {
2122
storage[getIndex(r.getUuid())] = r;
2223
}
2324
}
2425

2526
public void save(Resume r) {
26-
if (getIndex(r.getUuid()) == -1) {
27+
int index = getIndex(r.getUuid());
28+
if (index == -1) {
2729
storage[size] = r;
2830
size++;
29-
} else if (getIndex(r.getUuid()) >= storageSize) {
31+
} else if (getIndex(r.getUuid()) >= storage_limit) {
3032
System.out.println("Resume[] overflow");
3133
} else {
3234
System.out.println(r.getUuid() + " already");
3335
}
3436
}
3537

3638
public Resume get(String uuid) {
37-
if (getIndex(uuid) == -1) {
39+
int index = getIndex(uuid);
40+
if (index == -1) {
3841
System.out.println("Error, resume not find");
3942
return null;
4043
}
4144
return storage[getIndex(uuid)];
4245
}
4346

4447
public void delete(String uuid) {
45-
if (getIndex(uuid) == -1) {
48+
int index = getIndex(uuid);
49+
if (index == -1) {
4650
System.out.println("Error, not find resume");
4751
} else {
48-
storage[getIndex(uuid)] = storage[size - 1];
52+
storage[index] = storage[size - 1];
4953
storage[size - 1] = null;
5054
size--;
5155
}

‎src/com/urise/webapp/storage/Storage.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
public interface Storage {
66

7-
public void clear();
7+
void clear();
88

9-
public void update(Resume r);
9+
void update(Resume r);
1010

11-
public void save(Resume r);
11+
void save(Resume r);
1212

13-
public Resume get(String uuid);
13+
Resume get(String uuid);
1414

15-
public void delete(String uuid);
15+
void delete(String uuid);
1616

17-
public Resume[] getAll();
17+
Resume[] getAll();
1818

19-
public int size();
19+
int size();
2020

2121
}

0 commit comments

Comments
 (0)