Skip to content

Conversation

@MikePuzanov
Copy link
Owner

No description provided.

BubbleSort.Sort(listInt, new CompareIntInDescendingOrder());
for (int i = 0; i < listInt.Count; ++i)
{
Assert.AreEqual(listInt[i], listCheck[i]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Наоборот, первый параметр --- что ожидали, второй --- что получили

{
Assert.AreEqual(listString[i], listCheck[i]);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Тестов маловато. Стоило проверить на пустом списке, на списке, где все элементы одинаковы, на null-ы в параметрах. Задача-то простая очень, время было :)

/// <param name="compare">компаратор</param>
public static void Sort<T>(List<T> list, Comparer<T> compare)
{
var lenght = list.Count;
Copy link
Collaborator

Choose a reason for hiding this comment

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

length

{
if (compare.Compare(list[j - 1], list[j]) >= 0)
{
//Swap(ref list[j], list[j + 1]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Закомментированный код не нужен

/// <typeparam name="T">тип класса</typeparam>
/// <param name="list">лист значений</param>
/// <param name="compare">компаратор</param>
public static void Sort<T>(List<T> list, Comparer<T> compare)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Лучше было принимать по интерфейсу, IComparer

public override int Compare(int value1, int value2)
{
return value1 <= value2 ? 1 : -1 ;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Тут и в аналогичном месте ниже стоило использовать =>

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