-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
first solution #1355
base: master
Are you sure you want to change the base?
first solution #1355
Conversation
storageSize = 0; | ||
lastIndex = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
java do this for you already
storageSize = 0; | |
lastIndex = 0; |
uniqueKey = false; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uniqueKey = false; | |
break; | |
return; |
@Override | ||
public void put(K key, V value) { | ||
boolean uniqueKey = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you dont need it
boolean uniqueKey = true; |
keyArray[lastIndex] = key; | ||
valueArray[lastIndex] = value; | ||
storageSize++; | ||
lastIndex++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lastIndex++; |
private K[] keyArray; | ||
private V[] valueArray; | ||
private int storageSize; | ||
private int lastIndex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you dont need it
private int lastIndex; |
} | ||
|
||
@Override | ||
public V get(K key) { | ||
for (int i = 0; i < keyArray.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (int i = 0; i < keyArray.length; i++) { | |
for (int i = 0; i < size; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have size
variable created specially for that purpose, so lets use it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz fix this
if ((keyArray[i] == null && key == null) | ||
|| (keyArray[i] != null && keyArray[i].equals(key))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ((keyArray[i] == null && key == null) | |
|| (keyArray[i] != null && keyArray[i].equals(key))) { | |
if (key == keyArray[i] || key != null && key.equals(keyArray[i])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's more convenient way to compare them with identic results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz fix this
i cannot delete variable size because i cannot use in this task data structures |
i cannot delete variable size because i cannot use in this task data structures |
} | ||
|
||
@Override | ||
public V get(K key) { | ||
for (int i = 0; i < keyArray.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have size
variable created specially for that purpose, so lets use it
if ((keyArray[i] == null && key == null) | ||
|| (keyArray[i] != null && keyArray[i].equals(key))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's more convenient way to compare them with identic results
public StorageImpl() { | ||
keyArray = (K[]) new Object[ARRAY_LENGTH]; | ||
valueArray = (V[]) new Object[ARRAY_LENGTH]; | ||
size = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int
variables are zero by default. no need to repeat it by yourself
size = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix comments
} | ||
|
||
@Override | ||
public V get(K key) { | ||
for (int i = 0; i < keyArray.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz fix this
if ((keyArray[i] == null && key == null) | ||
|| (keyArray[i] != null && keyArray[i].equals(key))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz fix this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check and fix comments
…ion of the loop of size value
No description provided.