Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

first solution #1355

wants to merge 5 commits into from

Conversation

KoderNL
Copy link

@KoderNL KoderNL commented Dec 5, 2023

No description provided.

Comment on lines 15 to 16
storageSize = 0;
lastIndex = 0;

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

Suggested change
storageSize = 0;
lastIndex = 0;

Comment on lines 26 to 27
uniqueKey = false;
break;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uniqueKey = false;
break;
return;

@Override
public void put(K key, V value) {
boolean uniqueKey = true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you dont need it

Suggested change
boolean uniqueKey = true;

keyArray[lastIndex] = key;
valueArray[lastIndex] = value;
storageSize++;
lastIndex++;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lastIndex++;

private K[] keyArray;
private V[] valueArray;
private int storageSize;
private int lastIndex;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you dont need it

Suggested change
private int lastIndex;

}

@Override
public V get(K key) {
for (int i = 0; i < keyArray.length; i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (int i = 0; i < keyArray.length; i++) {
for (int i = 0; i < size; i++) {

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plz fix this

Comment on lines 41 to 42
if ((keyArray[i] == null && key == null)
|| (keyArray[i] != null && keyArray[i].equals(key))) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ((keyArray[i] == null && key == null)
|| (keyArray[i] != null && keyArray[i].equals(key))) {
if (key == keyArray[i] || key != null && key.equals(keyArray[i])) {

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plz fix this

@KoderNL KoderNL requested a review from kerrrusha December 6, 2023 11:54
@KoderNL
Copy link
Author

KoderNL commented Dec 6, 2023

i cannot delete variable size because i cannot use in this task data structures

@KoderNL KoderNL marked this pull request as draft December 6, 2023 11:55
@KoderNL
Copy link
Author

KoderNL commented Dec 6, 2023

i cannot delete variable size because i cannot use in this task data structures

@KoderNL KoderNL marked this pull request as ready for review December 6, 2023 12:07
}

@Override
public V get(K key) {
for (int i = 0; i < keyArray.length; i++) {

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

Comment on lines 41 to 42
if ((keyArray[i] == null && key == null)
|| (keyArray[i] != null && keyArray[i].equals(key))) {

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;

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

Suggested change
size = 0;

@KoderNL KoderNL requested a review from kerrrusha December 6, 2023 14:20
Copy link

@Sanderfuck Sanderfuck left a 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++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plz fix this

Comment on lines 41 to 42
if ((keyArray[i] == null && key == null)
|| (keyArray[i] != null && keyArray[i].equals(key))) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plz fix this

Copy link

@Sanderfuck Sanderfuck left a 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

@KoderNL KoderNL requested a review from Sanderfuck December 7, 2023 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants