-
Notifications
You must be signed in to change notification settings - Fork 0
Queue #10
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
base: master
Are you sure you want to change the base?
Queue #10
Conversation
yurii-litvinov
left a comment
There was a problem hiding this 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); |
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Пространства имён в .NET именуются с заглавной
| public int Priority { get; set; } | ||
|
|
||
| public int Value { get; set; } | ||
|
|
||
| public Node Next { get; set; } |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Гм. Если самый большой приоритет прячется в голове очереди, что будет? Мы же его пропустим тут?
No description provided.