55import java .util .Arrays ;
66
77public 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 }
0 commit comments