Skip to content

hw8#2

Open
dmithorzh wants to merge 2 commits intoiaulitin:mainfrom
dmithorzh:main
Open

hw8#2
dmithorzh wants to merge 2 commits intoiaulitin:mainfrom
dmithorzh:main

Conversation

@dmithorzh
Copy link

No description provided.

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/out/
/.idea/
Copy link
Owner

Choose a reason for hiding this comment

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

Отлично, что дополнил!
Для полноты нужно еще *.iml добавить.

return null;
}

public static void main(String [] args){
Copy link
Owner

Choose a reason for hiding this comment

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

main лучше выносить в отдельный класс.

}

public static void main(String [] args){
DimbossArrayList<Integer> testList=new DimbossArrayList<>();
Copy link
Owner

Choose a reason for hiding this comment

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

Все еще проблемы с форматированием.
Не забывай про ctrl + alt + L.

}

@Override
public <E1> E1[] toArray(E1[] a) {
Copy link
Owner

Choose a reason for hiding this comment

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

А зачем еще один дженерик ввел? У тебя же есть общий для всего класса - E


private E[] listArr;
private int size;
private static final int DEFAULT_SIZE=10;
Copy link
Owner

Choose a reason for hiding this comment

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

Круто, что выделил в константу

public boolean add(E t) {
add(size, t);
return true;
}
Copy link
Owner

Choose a reason for hiding this comment

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

Я бы предложил методы группировать пологичнее. Например, помещать перегруженные add рядом друг с другом. remove тоже рядом.

public boolean remove(Object o) {
int i;
for (i = 0; i < size; i++)
if (listArr[i] == o)
Copy link
Owner

Choose a reason for hiding this comment

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

А почему через == сравниваешь, а не через equals?

return null;
}

public static void main(String [] args){
Copy link
Owner

Choose a reason for hiding this comment

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

Не провел сравнение производительности своей реализации ArrayList со стандартной

@Override
public int indexOf(Object o) {
for (int i = 0; i < size; i++)
if (listArr[i] == o)
Copy link
Owner

Choose a reason for hiding this comment

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

А почему через == сравниваешь, а не через equals?

}

@Override
public boolean remove(Object o) {
Copy link
Owner

Choose a reason for hiding this comment

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

Слушай, а почему бы тебе не осуществлять здесь поиск по объекту с определением индекса, а потом вызвать remove по индексу? Переиспользуешь код почти нахаляву.

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

Comments