Skip to content

Conversation

@MikePuzanov
Copy link
Owner

No description provided.

Copy link
Collaborator

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

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

С технической точки зрения всё более-менее прилично, но с алгоритмической — качество решения можно охарактеризовать фразой "Заблудились в трёх соснах" :)

functionResult = queue.Dequeue();
Assert.AreEqual(result1[2], functionResult);
functionResult = queue.Dequeue();
Assert.AreEqual(result1[3], functionResult);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Честно говоря, не очень понятно, зачем-таки result. Можно было просто проверить на равенство 5, 7 и т.д.

@@ -0,0 +1,32 @@
using System;

namespace test2
Copy link
Collaborator

Choose a reason for hiding this comment

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

Пространства имён в .NET именуются с заглавной

Comment on lines +15 to +19
public int Priority { get; set; }

public int Value { get; set; }

public Node Next { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Действительно ли им всем нужны public-сеттеры? Ведь если значение попадает в очередь, оно уже не меняется, да и приоритет его тоже.

private Node tail;

public Queue()
=> head = null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Он и так null, тем более что tail Вы не инициализируете :)

node.Next = tail;
}

private Node runner;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Лучше все поля и все методы объявлять рядом, не перемешивая, тем более что конкретно у этой штуки нет ни одной причины быть полем (она всегда инициализируется в методе перед использованием, следовательно состояние объекта на самом деле не хранит, следовательно могла бы быть локальной переменной).

/// <summary>
/// function remove from queue
/// </summary>
/// <returns>value's array with max priority</returns>
Copy link
Collaborator

Choose a reason for hiding this comment

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

"Массив значения", что? :)


namespace test2
{
public class QueueException : Exception
Copy link
Collaborator

Choose a reason for hiding this comment

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

Тоже нужны комментарии

}
if (runner.Priority == maxPriority && runner.Next == null)
{
result = runner.Next.Value;
Copy link
Collaborator

Choose a reason for hiding this comment

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

runner.Next == null же, иначе мы бы сюда не попали. runner.Next.Value --- это NullReferenceException

Node previosNode = null;
while (runner.Next != null)
{
if (runner.Next.Priority == maxPriority)
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.

3 participants