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

implemented class ArrayList #1201

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

Conversation

Tonny-gif
Copy link

No description provided.

Comment on lines 35 to 40
growIfArrayFull();
for (int i = 0; i < list.size(); i++) {
growIfArrayFull();
this.elementData[size] = list.get(i);
size++;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
growIfArrayFull();
for (int i = 0; i < list.size(); i++) {
growIfArrayFull();
this.elementData[size] = list.get(i);
size++;
}
for (int i = 0; i < list.size(); i++) {
add(list.get(i));
}

Comment on lines 45 to 47
if (index < 0 || index >= size) {
throw new ArrayListIndexOutOfBoundsException("incorrect index");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

image

return size == 0;
}

public int index(T element) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public int index(T element) {
private int getIndex(T element) {

public class ArrayList<T> implements List<T> {
private static final int DEFAULT_CAPACITY = 10;
private static final double MIN_CAPACITY = 1.5;
Copy link
Contributor

Choose a reason for hiding this comment

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

it is not MIN_CAPACITY - think about name

@Tonny-gif Tonny-gif requested a review from Rommelua October 30, 2023 08:53
}
}

private void indexChecker(int index) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private void indexChecker(int index) {
private void checkIndex(int index) {

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.

2 participants